Skip to content

Instantly share code, notes, and snippets.

View magevision's full-sized avatar

MageVision magevision

View GitHub Profile
@magevision
magevision / config.xml
Last active January 9, 2024 09:20
AddCustomConfigVariable
<?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>
<general>
<store_information>
<support_email_address>support@magevision.com</support_email_address>
</store_information>
</general>
</default>
@magevision
magevision / InstallCustomerCustomGroup.php
Created October 9, 2023 13:19
CreateCustomerGroupProgrammatically
<?php
declare(strict_types=1);
namespace MageVision\Blog90\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchRevertableInterface;
use Magento\Tax\Api\Data\TaxClassKeyInterface;
@magevision
magevision / Cron_Post.php
Last active June 8, 2023 08:38
CreateACronWithConfigPath
<?php
declare(strict_types=1);
namespace MageVision\Blog89\Cron;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
class Post
@magevision
magevision / CreateCustomOrderStatus.php
Last active May 24, 2023 15:10
AddCustomOrderStatusProgrammatically
<?php
declare(strict_types=1);
namespace MageVision\Blog88\Setup\Patch\Data;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Sales\Model\Order;
@magevision
magevision / CreateInventorySource.php
Created May 11, 2023 13:54
CreateAnInventorySourceProgrammatically
<?php
declare(strict_types=1);
namespace MageVision\Blog87\Setup\Patch\Data;
use Magento\Framework\Api\DataObjectHelper;
use Magento\Framework\Setup\ModuleDataSetupInterface as ModuleDataSetupInterfaceAlias;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\InventoryApi\Api\Data\SourceInterface;
@magevision
magevision / StockManagement.php
Created May 11, 2023 08:44
AddCustomInventoryAttributeProgrammatically
<?php
namespace MageVision\Blog86\Model;
use Magento\CatalogInventory\Api\StockRegistryInterface;
use Magento\Framework\Exception\NoSuchEntityException;
class StockManagement
{
private StockRegistryInterface $stockRegistry;
@magevision
magevision / StockManagement.php
Last active May 2, 2023 13:47
UpdateProductStockMSIProgrammatically
<?php
namespace MageVision\Blog85\Model;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Validation\ValidationException;
use Magento\InventoryApi\Api\Data\SourceItemInterface;
use Magento\InventoryApi\Api\GetSourceItemsBySkuInterface;
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="product.info.type">
...............................
</referenceContainer>
</body>
</page>
@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;