Skip to content

Instantly share code, notes, and snippets.

View magefast's full-sized avatar
🥶

Alex S magefast

🥶
View GitHub Profile
@magefast
magefast / tips.sh
Last active February 5, 2025 20:10
tips
#count files
ls -1 | wc -l
#
find . -maxdepth 1 -type d | while read -r dir
do printf "%s:\t" "$dir"; find "$dir" -type f | wc -l; done
# find biggest folders
du -k /home | sort -n | tail -10
@magefast
magefast / Add attribute to attribute set
Created January 19, 2022 17:35
Add attribute to attribute set
<?php
$locale = 'en_US';
Mage::getSingleton('core/session')->setMyLang($langCode);
$locale = Mage::getSingleton('core/session')->getMyLang();
Mage::getSingleton('core/translate')->setLocale($locale)->init('frontend', true);
$defaultStore = Mage::app()->getStore()->getCode();
@ppcdias
ppcdias / magento2-disable-unused-modules.sh
Last active July 21, 2025 17:55
Magento 2.4 Disable Unused Modules to Increase Performance
# magento 2 disable unused modules
bin/magento module:disable Vertex_AddressValidation
bin/magento module:disable Vertex_AddressValidationApi
bin/magento module:disable Vertex_Tax
bin/magento module:disable Temando_ShippingRemover
bin/magento module:disable Dotdigitalgroup_Chat
bin/magento module:disable Dotdigitalgroup_Email
@tao-s
tao-s / sample.json
Created December 13, 2020 23:57
ShippingDetails sample
"shippingDetails": [
{
"@type": "OfferShippingDetails",
"shippingRate": {
"@type": "MonetaryAmount",
"value": "610",
"currency": "JPY"
},
"shippingDestination": {
"@type": "DefinedRegion",
@webmasterninjay
webmasterninjay / downloader.php
Created September 26, 2019 14:33
Simple PHP script to download file from url
<html>
<form method="post">
<input name="url" size="50" />
<input name="submit" type="submit" />
</form>
<?php
// maximum execution time in seconds
set_time_limit (24 * 60 * 60);
if (!isset($_POST['submit'])) die();
@ananth-iyer
ananth-iyer / CsrfValidatorSkip.php
Last active October 30, 2023 10:33
Magento 2.3.0: Implement below code to skip the CSRF check on your custom route called outside Magento environment. This implementation does not break core frontend/adminhtml routes, Magento 2.3/2.2/2.1 web stores.
<?php
namespace Vendor\Module\Plugin;
class CsrfValidatorSkip
{
/**
* @param \Magento\Framework\App\Request\CsrfValidator $subject
* @param \Closure $proceed
* @param \Magento\Framework\App\RequestInterface $request
* @param \Magento\Framework\App\ActionInterface $action
@Nil79
Nil79 / MyScript.php
Created March 8, 2019 16:11
Magento2 - script to create a simple product programmatically
<?php
class MyScript
extends \Magento\Framework\App\Http
implements \Magento\Framework\AppInterface {
protected $_productRepository;
protected $_productFactory;
// Tramite la Dependcy Injection possiamo passare al costruttore delle classi Magento, diverse tipologie di classi
@magefast
magefast / Magento - add attribute to Attribute Set
Last active August 7, 2020 17:15
Magento - add attribute to all Attribute Sets
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once './app/Mage.php';
$attributeCode = 'faktstock_sklad';
$groupName = 'Для Заказа';
Mage::app();
Mage::getSingleton('core/translate')->setLocale('en_US')->init('frontend', true);
@ProcessEight
ProcessEight / Anatomy of Magento 2: Layered Navigation.md
Last active August 8, 2025 16:01
In-depth exploration of how layered navigation is implemented in Magento 2

Anatomy of Magento 2: Layered Navigation

Points for investigation

  • Generate high-level overview of all the main components
  • How are the total item counts for each option generated?
  • How is the catalog updated to display the matching products?
  • How are options rendered?
  • What are the customisation points?
  • What events are dispatched?
@Nil79
Nil79 / Csv.php
Last active July 14, 2023 07:36
Add mass action in Order Grid in Magento 2.2
<?php
namespace Vendor\ModuleName\Controller\Adminhtml\Export;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;