Skip to content

Instantly share code, notes, and snippets.

View magevision's full-sized avatar

MageVision magevision

View GitHub Profile
@magevision
magevision / di.xml
Created March 30, 2022 11:46
GetConfigValueInsideEmailTemplate
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="general">
<group id="store_information">
<field id="custom_store_config" translate="label" type="text" sortOrder="65" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Custom Store Config</label>
</field>
</group>
</section>
@magevision
magevision / Orders.php
Created January 25, 2022 12:37
GetOrdersByPaymentMethod
<?php
declare(strict_types=1);
namespace MageVision\Blog72\Block;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
@magevision
magevision / CreateCmsBlock.php
Created October 6, 2021 12:23
CreateCmsBlock
<?php
declare(strict_types=1);
namespace MageVision\Blog71\Setup\Patch\Data;
use Magento\Cms\Model\BlockFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
@magevision
magevision / CreateCmsPage.php
Created October 6, 2021 09:17
CreateCmsPageDataPatch
<?php
declare(strict_types=1);
namespace MageVision\Blog70\Setup\Patch\Data;
use Magento\Cms\Model\PageFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
@magevision
magevision / customer_account.xml
Created October 1, 2021 09:51
How to Add a Custom Link in My Account Navigation
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="customer_account_navigation">
<block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-custom-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">Custom Link Label</argument>
<argument name="path" xsi:type="string">module/controller/action</argument>
<argument name="sortOrder" xsi:type="number">300</argument>
</arguments>
</block>
@magevision
magevision / view.xml
Last active September 12, 2021 11:27
HideConfigurableProductImagesOnVisualSwatchChange
<vars module="Magento_ConfigurableProduct">
<var name="gallery_switch_strategy">prepend</var>
</vars>
@magevision
magevision / Checkmo.php
Created February 7, 2021 16:29
AddImageLogotoPaymentMethodinCheckout
<?php
namespace MageVision\Blog67\Model;
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\Api\ExtensionAttributesFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Model\Context;
use Magento\Framework\Registry;
use Magento\Framework\UrlInterface;
@magevision
magevision / di.xml
Created January 23, 2021 16:20
ChangeIncrementIdsLength
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Framework\DB\Sequence\SequenceInterface">
<arguments>
<argument name="pattern" xsi:type="string">%s%'.05d%s</argument>
</arguments>
</type>
</config>
<?php
declare(strict_types=1);
namespace MageVision\GreekRegions\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
class AddGreekRegions implements DataPatchInterface
@magevision
magevision / ProfilerCommand.php
Created December 1, 2020 14:07
UseProfilerInCLICommand
<?php
namespace MageVision\Blog64\Console\Command;
use Magento\Directory\Model\ResourceModel\Country\CollectionFactory;
use Magento\Framework\Console\Cli;
use Magento\Framework\Profiler\Driver\Standard\Stat;
use Magento\Framework\Profiler\Driver\Standard\StatFactory;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;