Skip to content

Instantly share code, notes, and snippets.

View magevision's full-sized avatar

MageVision magevision

View GitHub Profile
@magevision
magevision / default.xml
Last active March 7, 2023 08:33
AddCustomAdminNotice
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="global_notices">
<action method="setTemplate">
<argument name="template" xsi:type="string">MageVision_Blog83::page/notices.phtml</argument>
</action>
</referenceBlock>
</body>
</page>
@magevision
magevision / CustomValidationRule.php
Created November 29, 2022 10:13
QuoteBackendValidationRule
<?php
declare(strict_types=1);
namespace MageVision\Blog80\Model\Quote\ValidationRule;
use Magento\Framework\Validation\ValidationResultFactory;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\ValidationRules\QuoteValidationRuleInterface;
@magevision
magevision / ProfilerCommand.php
Last active January 19, 2023 08:42
SetNameToACustomCLICommand
<?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;
@magevision
magevision / product_types.xml
Last active October 10, 2022 11:45
CustomProductTypeCompositeProducts
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd">
................
<composableTypes>
<type name="magevision_new_product_type" />
</composableTypes>
</config>
@magevision
magevision / SetStoreConfiguration.php
Last active October 10, 2022 11:44
StoreConfigurationUsingDataPatch
<?php
declare(strict_types=1);
namespace MageVision\Blog79\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Config\Model\ResourceModel\Config as ResourceConfig;
@magevision
magevision / config.xml
Last active October 10, 2022 11:41
CreateAPaymentMethodOnlyVisibleInAdmin
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<payment>
<admin_only>
<active>1</active>
<title>Admin Payment Only</title>
<order_status>pending</order_status>
<allowspecific>0</allowspecific>
<can_use_internal>1</can_use_internal>
@magevision
magevision / CheckmoPlugin
Last active September 15, 2022 14:44
MakeAPaymentMethodOnlyVisibleInAdmin
<?php
namespace MageVision\Blog77\Plugin\OfflinePayments\Model;
use Magento\Backend\Model\Auth\Session;
use Magento\OfflinePayments\Model\Checkmo;
use Magento\Quote\Api\Data\CartInterface;
class CheckmoPlugin
{
@magevision
magevision / catalog_category_view.xml
Created May 9, 2022 11:44
DisplayRecentlyViewedProductsProgrammatically
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Widget\RecentlyViewed" name="recently_viewed"
template="Magento_Catalog::product/widget/viewed/grid.phtml" after="-">
<arguments>
<argument name="uiComponent" xsi:type="string">widget_recently_viewed</argument>
<argument name="page_size" xsi:type="number">4</argument>
<argument name="show_attributes" xsi:type="string">name,image,price,learn_more</argument>
@magevision
magevision / EmailNotificationPlugin.php
Created May 6, 2022 12:38
DisableCustomerWelcomeEmail
<?php
namespace MageVision\Blog75\Plugin\Customer\Model;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\EmailNotification;
class EmailNotificationPlugin
{
/**
@magevision
magevision / events.xml
Created April 19, 2022 13:03
DisableEventObserver
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sendfriend_product">
<observer name="reports" disabled="true" />
</event>
</config>