How To Set Tier Price With Percentage Value Programmatically in Magento 2.x

There are following below steps to create custom module  to add or update tier price in Magento2

Here, we are considering as
Namespace / ModuleName = Mage2db/John

Magento 2 Custom Module

Step [1.1] – Create registration.php file under your module [ Namespace / ModuleName ]

File Path=Mage2db/John/registration.php

Add below content in this file.

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Mage2db_John',
    __DIR__
);

Step [1.2] – Create module.xml file under your module [ Namespace / ModuleName ]

File Path=Mage2db/John/etc/module.xml

Add below content in this file.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mage2db_John" setup_version="1.0.0" />
</config>

Step [2] – Create Index.php file under your module etc directory. Add below content in this file.

File Path=Mage2db/John/Controller/Index/Index.php

Here, we are using below core class to add tier or customer group price

Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
Magento\Catalog\Api\ScopedProductTierPriceManagementInterface;

<?php
namespace Mage2db\John\Controller\Index;

use Magento\Backend\App\Action\Context;
use \Magento\Framework\Controller\ResultFactory;
use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
use Magento\Catalog\Api\ScopedProductTierPriceManagementInterface;

class Index extends \Magento\Framework\App\Action\Action
{
	
    /**
     * @var \Magento\Framework\App\Cache\TypeListInterface
     */
    protected $_cacheTypeList;

    /**
     * @var \Magento\Framework\App\Cache\StateInterface
     */
    protected $_cacheState;

    /**
     * @var \Magento\Framework\App\Cache\Frontend\Pool
     */
    protected $_cacheFrontendPool;

    /**
     * @var \Magento\Framework\View\Result\PageFactory
     */
    protected $resultPageFactory;
	
	/**
     * @var ScopedProductTierPriceManagementInterface
     */
    private $tierPrice;
 
    /**
     * @var ProductTierPriceInterfaceFactory
     */
    private $productTierPriceFactory;

    /**
     * @param Action\Context $context
     * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
     * @param \Magento\Framework\App\Cache\StateInterface $cacheState
     * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
     * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
     */
    public function __construct(
       \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
        \Magento\Framework\App\Cache\StateInterface $cacheState,
        \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool,
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory,
		ScopedProductTierPriceManagementInterface $tierPrice,
        ProductTierPriceInterfaceFactory $productTierPriceFactory
    ) {
        parent::__construct($context);
        $this->_cacheTypeList = $cacheTypeList;
        $this->_cacheState = $cacheState;
        $this->_cacheFrontendPool = $cacheFrontendPool;
        $this->resultPageFactory = $resultPageFactory;
        $this->_messageManager = $messageManager;
	$this->tierPrice = $tierPrice;
        $this->productTierPriceFactory =  $productTierPriceFactory;
		
     }
    
    /**
     * Flush cache storage
     *
     */
    public function execute()
    {
	$qty = 2.00;//Quantity must be float value
        $price = 300.00;//Price must be float value
        $customerGroupId = 4; //CustomerGroup ID
        $sku = 'product1021'; //put sku,to add tier price
/*As per your need all above values create dynamically */
        try {
            $tierPriceData = $this->productTierPriceFactory->create();
            $tierPriceData->setCustomerGroupId($customerGroupId)->setQty($qty)->setValue($price);

//Adding Discount Percentage Value
$percentage_value="8.00"; //must be float value
$extensionAttributes = $tierPriceData->getExtensionAttributes();
$extensionAttributes->setPercentageValue($percentage_value);
$tierPriceData->setExtensionAttributes($extensionAttributes);

$tierPrice = $this->tierPrice->add($sku, $tierPriceData);
        } catch (NoSuchEntityException $exception) {
            throw new NoSuchEntityException(__($exception->getMessage()));
        }
		
echo"Tier Price / Customer Group Price, with Quantity, Price, Discount Percentage Value has been updated for SKU=$sku";
exit();
		
  $this->resultPage = $this->resultPageFactory->create();  
        return $this->resultPage;
    }
}

Step [3] – Create routes.xml file under your module etc directory. Add below content in this file.

File Path=Mage2db\John\etc\frontend\routes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
   <router id="standard">
       <route id="john" frontName="john">
         <module name="Mage2db_John" />
       </route>
   </router>
</config>

Step [3] – Run URL https://mage2db.com/john/index/index

Change https://mage2db.com to your Base URL.

Finally Tier Price / Customer Group Price, with Quantity, Price, Discount Percentage Value, custom module has been created.

How To Create Events & Observer Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Preference Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Plugin Using Custom Module in Magento / Adobe Commerce 2.x


How To Get Base URL in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Module in Magento 2.x / Adobe Commerce 2.x


How To Add Custom Block on Cart Page in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Log File in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Controller in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Console Command in Magento 2.x / Adobe Commerce 2.x


How To Add Customer Groups Dropdown in Magento 2.x Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.


How To Get all Customers Data in Magento 2.x / Adobe Commerce 2.x


How To Set Tier Price With Percentage Value Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Tier Price Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Websites Dropdown in Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.x


Magento 2 All Database Tables [500 & more Tables]


How To Set Multi Shipping Settings In Magento 2


How To Set Origin Shipping in Magento 2


Difference Between Offline Shipping Method and Online Shipping Method


Magento 2 Online Customers Options



How To Apply Customer Group Price of Products in Magento 2


How To Add Customer Groups Dropdown in Magento 2 Admin Form and Grid By UI Component


How To Get all Customers Data in Magento 2


How To Create Customer Order in Magento 2 Admin Panel


Magento 2 Login As Customer Not Enabled


How To Configure Customer Account Sharing Options in Magento 2


Magento 2 Redirect To Customer Dashboard After Login


Which Magento 2 database table store customer shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 database table store customer’s Email Data


Which Magento 2 Database Table Store Customer Newsletter Data


Which Magento 2 database table store customer’s shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 Database Tables Store Customer Rating


Which Magento 2 Database Tables Store Customer Wishlist Products


Magento 2 Increase Customer Session Time


Which Magento 2 Database Table Store Patches

How To Create Custom Controller in Magento 2.x

There are following below steps need to follow to create custom controller in Magento 2.

We are creating Custom Module for Custom Controller.

Step [1] – Create registration.php file under your module [ Namespace / ModuleName ]

File Path=Mage2db/John/registration.php

Add below content in this file.

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Mage2db_John',
    __DIR__
);

Step [2] – Create module.xml file under your module [ Namespace / ModuleName ]

File Path=Mage2db/John/etc/module.xml

Add below content in this file.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mage2db_John" setup_version="1.0.0" />
</config>

Steps [3] – Create routes.xml file under your module etc directory. Add below content in this file.

File Path=Mage2db\John\etc\frontend\routes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
   <router id="standard">
       <route id="john" frontName="john">
         <module name="Mage2db_John" />
       </route>
   </router>
</config>

Step [4] – Create Controller Index.php file under your module Controller Index directory. Add below content in this file.

File Path=Mage2db/John/Controller/Index/Index.php

<?php

namespace  Mage2db\John\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action
{
     public function execute()
     {
         echo 'Hello Mage2DB Magento 2 Learning & Knowledge & Troubleshooting';
         exit();
     }
}

All storefront controllers have to contain a public execute method. It is called when accessing the controller.
The storefront controllers are inherited from \Magento\Framework\App\Action\Action class.

Magento 2 Standard, use of the echo & exit () is totally prohibited here we have used only for Testing Purpose.

Step [5] – Finally your custom controller has been created

Run the following below commands at your Magento 2 root directory


php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush

Run below URL

https://mage2db.com/john/index/index

Change https://mage2db.com to your Base URL, Output as below

 Hello Mage2DB Magento 2 Learning & Knowledge & Troubleshooting 

How To Create Events & Observer Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Preference Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Plugin Using Custom Module in Magento / Adobe Commerce 2.x


How To Get Base URL in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Module in Magento 2.x / Adobe Commerce 2.x


How To Add Custom Block on Cart Page in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Log File in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Controller in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Console Command in Magento 2.x / Adobe Commerce 2.x


How To Add Customer Groups Dropdown in Magento 2.x Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.


How To Get all Customers Data in Magento 2.x / Adobe Commerce 2.x


How To Set Tier Price With Percentage Value Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Tier Price Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Websites Dropdown in Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.x


Magento 2 All Database Tables [500 & more Tables]


How To Set Multi Shipping Settings In Magento 2


How To Set Origin Shipping in Magento 2


Difference Between Offline Shipping Method and Online Shipping Method


Magento 2 Online Customers Options



How To Apply Customer Group Price of Products in Magento 2


How To Add Customer Groups Dropdown in Magento 2 Admin Form and Grid By UI Component


How To Get all Customers Data in Magento 2


How To Create Customer Order in Magento 2 Admin Panel


Magento 2 Login As Customer Not Enabled


How To Configure Customer Account Sharing Options in Magento 2


Magento 2 Redirect To Customer Dashboard After Login


Which Magento 2 database table store customer shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 database table store customer’s Email Data


Which Magento 2 Database Table Store Customer Newsletter Data


Which Magento 2 database table store customer’s shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 Database Tables Store Customer Rating


Which Magento 2 Database Tables Store Customer Wishlist Products


Magento 2 Increase Customer Session Time


Which Magento 2 Database Table Store Patches

How To Apply Customer Group Price of Products in Magento 2.x

There are following below link define brief explanation “How To Apply Customer Group Price of products in Magento 2

How To Create Events & Observer Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Preference Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Plugin Using Custom Module in Magento / Adobe Commerce 2.x


How To Get Base URL in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Module in Magento 2.x / Adobe Commerce 2.x


How To Add Custom Block on Cart Page in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Log File in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Controller in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Console Command in Magento 2.x / Adobe Commerce 2.x


How To Add Customer Groups Dropdown in Magento 2.x Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.


How To Get all Customers Data in Magento 2.x / Adobe Commerce 2.x


How To Set Tier Price With Percentage Value Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Tier Price Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Websites Dropdown in Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.x


Magento 2 All Database Tables [500 & more Tables]


How To Set Multi Shipping Settings In Magento 2


How To Set Origin Shipping in Magento 2


Difference Between Offline Shipping Method and Online Shipping Method


Magento 2 Online Customers Options



How To Apply Customer Group Price of Products in Magento 2


How To Add Customer Groups Dropdown in Magento 2 Admin Form and Grid By UI Component


How To Get all Customers Data in Magento 2


How To Create Customer Order in Magento 2 Admin Panel


Magento 2 Login As Customer Not Enabled


How To Configure Customer Account Sharing Options in Magento 2


Magento 2 Redirect To Customer Dashboard After Login


Which Magento 2 database table store customer shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 database table store customer’s Email Data


Which Magento 2 Database Table Store Customer Newsletter Data


Which Magento 2 database table store customer’s shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 Database Tables Store Customer Rating


Which Magento 2 Database Tables Store Customer Wishlist Products


Magento 2 Increase Customer Session Time


Which Magento 2 Database Table Store Patches

What is Magento 2.x Tier Price

Tier prices are specific promotional technique to provide different set of discount on products, on the bases of product’s quantity, product’s discount applied.

Magento 2 store owner , apply this promotional technique , while customers are trying to purchase bulk products, normally this promotional technique for B2B business, on the special occasion B2C also apply to atrract more customers & generate more revenue

Example :: Here different set of discount applied of product (Affirm Water Bottle) as below

Step[1] – Tier Disocunt – 1

Buy 6 For $5.95 Each and Save 15%

Step[2] – Tier Disocunt – 2

Buy 12 For $5.60 Each and Save 20%

Step[3] – Tier Disocunt – 3

Buy 24 For $5.25 Each and Save 25%

Here three set of discount apply on the bases of quantity.

How To Convert JSON To Array of Nested Objects in Magento 2.x

There are following below method to converts JSON to Array of Nested Objects in Magento 2

\Magento\Framework\Serialize\Serializer\Json

public function __construct(
        \Magento\Framework\Serialize\Serializer\Json $json
    ) {
        $this->json = $json;
    }

 public function CustomFunction()
 {
   $jsonDecode = $this->json->unserialize($result);

   $json = $this->json->serialize($jsonDecode);

 }

Magento 2 All Database Tables [500 & more Tables]


How To Set Multi Shipping Settings In Magento 2


How To Set Origin Shipping in Magento 2


Difference Between Offline Shipping Method and Online Shipping Method


Magento 2 Online Customers Options



How To Apply Customer Group Price of Products in Magento 2



How To Add Customer Groups Dropdown in Magento 2 Admin Form and Grid By UI Component


How To Get all Customers Data in Magento 2


How To Create Customer Order in Magento 2 Admin Panel


Magento 2 Login As Customer Not Enabled


How To Configure Customer Account Sharing Options in Magento 2


Magento 2 Redirect To Customer Dashboard After Login


Which Magento 2 database table store customer shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 database table store customer’s Email Data


Which Magento 2 Database Table Store Customer Newsletter Data


Which Magento 2 database table store customer’s shipping and billing address



How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 Database Tables Store Customer Rating


Which Magento 2 Database Tables Store Customer Wishlist Products



Magento 2 Increase Customer Session Time


Which Magento 2 Database Table Store Patches

How To Add Tier Price in Magento 2.x Programmatically

There are following below steps to create custom module  to add or update tier price in Magento2

Here, we are considering as
Namespace / ModuleName = Mage2db/John

Magento 2 Custom Module

Step [1.1] – Create registration.php file under your module [ Namespace / ModuleName ]

File Path=Mage2db/John/registration.php

Add below content in this file.

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Mage2db_John',
    __DIR__
);

Step [1.2] – Create module.xml file under your module [ Namespace / ModuleName ]

File Path=Mage2db/John/etc/module.xml

Add below content in this file.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Mage2db_John" setup_version="1.0.0" />
</config>

Step [2] – Create Index.php file under your module Controller Index directory. Add below content in this file.

File Path=Mage2db/John/Controller/Index/Index.php

Here, we are using below core class to add tier or customer group price

Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
Magento\Catalog\Api\ScopedProductTierPriceManagementInterface;

<?php
namespace Mage2db\John\Controller\Index;

use Magento\Backend\App\Action\Context;
use \Magento\Framework\Controller\ResultFactory;
use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
use Magento\Catalog\Api\ScopedProductTierPriceManagementInterface;

class Index extends \Magento\Framework\App\Action\Action
{
	
    /**
     * @var \Magento\Framework\App\Cache\TypeListInterface
     */
    protected $_cacheTypeList;

    /**
     * @var \Magento\Framework\App\Cache\StateInterface
     */
    protected $_cacheState;

    /**
     * @var \Magento\Framework\App\Cache\Frontend\Pool
     */
    protected $_cacheFrontendPool;

    /**
     * @var \Magento\Framework\View\Result\PageFactory
     */
    protected $resultPageFactory;
	
	/**
     * @var ScopedProductTierPriceManagementInterface
     */
    private $tierPrice;
 
    /**
     * @var ProductTierPriceInterfaceFactory
     */
    private $productTierPriceFactory;

    /**
     * @param Action\Context $context
     * @param \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList
     * @param \Magento\Framework\App\Cache\StateInterface $cacheState
     * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool
     * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
     */
    public function __construct(
       \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
        \Magento\Framework\App\Cache\StateInterface $cacheState,
        \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool,
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory,
		ScopedProductTierPriceManagementInterface $tierPrice,
        ProductTierPriceInterfaceFactory $productTierPriceFactory
    ) {
        parent::__construct($context);
        $this->_cacheTypeList = $cacheTypeList;
        $this->_cacheState = $cacheState;
        $this->_cacheFrontendPool = $cacheFrontendPool;
        $this->resultPageFactory = $resultPageFactory;
        $this->_messageManager = $messageManager;
		$this->tierPrice = $tierPrice;
        $this->productTierPriceFactory = $productTierPriceFactory;
		
     }
    
    /**
     * Flush cache storage
     *
     */
    public function execute()
    {
	$qty = 2.00;//Quantity must be float value
        $price = 300.00;//Price must be float value
        $customerGroupId = 4; //CustomerGroup ID
        $sku = 'product1021'; //put sku,to add tier price
/*As per your need all above values create dynamically */
        try {
            $tierPriceData = $this->productTierPriceFactory->create();
            $tierPriceData->setCustomerGroupId($customerGroupId)->setQty($qty)->setValue($price);
            $tierPrice = $this->tierPrice->add($sku, $tierPriceData);
        } catch (NoSuchEntityException $exception) {
            throw new NoSuchEntityException(__($exception->getMessage()));
        }
		
		echo"Tier Price or Customer Group Price has been updated for SKU=$sku";
		exit();
		
	    $this->resultPage = $this->resultPageFactory->create();  
        return $this->resultPage;
    }
}

Step [3] – Create routes.xml file under your module etc directory. Add below content in this file.

File Path=Mage2db\John\etc\frontend\routes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
   <router id="standard">
       <route id="john" frontName="john">
         <module name="Mage2db_John" />
       </route>
   </router>
</config>

Step [3] – Run below URL

https://mage2db.com/john/index/index

Change https://mage2db.com to your Base URL.

Finally Tier Price / Customer Group Price, custom module has been created.

How To Create Events & Observer Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Preference Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Plugin Using Custom Module in Magento / Adobe Commerce 2.x


How To Get Base URL in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Module in Magento 2.x / Adobe Commerce 2.x


How To Add Custom Block on Cart Page in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Log File in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Controller in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Console Command in Magento 2.x / Adobe Commerce 2.x


How To Add Customer Groups Dropdown in Magento 2.x Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.


How To Get all Customers Data in Magento 2.x / Adobe Commerce 2.x


How To Set Tier Price With Percentage Value Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Tier Price Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Websites Dropdown in Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.x


Magento 2 All Database Tables [500 & more Tables]


How To Set Multi Shipping Settings In Magento 2


How To Set Origin Shipping in Magento 2


Difference Between Offline Shipping Method and Online Shipping Method


Magento 2 Online Customers Options



How To Apply Customer Group Price of Products in Magento 2


How To Add Customer Groups Dropdown in Magento 2 Admin Form and Grid By UI Component


How To Get all Customers Data in Magento 2


How To Create Customer Order in Magento 2 Admin Panel


Magento 2 Login As Customer Not Enabled


How To Configure Customer Account Sharing Options in Magento 2


Magento 2 Redirect To Customer Dashboard After Login


Which Magento 2 database table store customer shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 database table store customer’s Email Data


Which Magento 2 Database Table Store Customer Newsletter Data


Which Magento 2 database table store customer’s shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 Database Tables Store Customer Rating


Which Magento 2 Database Tables Store Customer Wishlist Products


Magento 2 Increase Customer Session Time


Which Magento 2 Database Table Store Patches

Which Magento 2.x Database Table Store Customer Group Price of products

There are following below Magento 2 database table store customer group price.

catalog_product_entity_tier_price

Advanced Pricing & Customer Group Pricing:: The following below steps need to follow.

Step [1] – Go To Magento 2 Admin

Catalog > Products

Step [2] – Display products listing

Step [3] – Once Click on Edit Button of product

Product Edit form display as below

Step [4] – Once click on Advanced Pricing

Select Website [Websites Drop Down]

Select Customer Group [Customer Groups Drop Down]

Fill Quantity

Select Price [ Price Drop Down (Fixed / Percentage)]

Fill fixed price on the bases of Group Selection

Finally click on Done & Save Button & Flush Cache

Step [5] – Database table store product pricing

Note:: Here Product ID -1

Name-Stylish Shirts

Price is $1000.00

as we have already filled Customer Group Price $100 in Step [4]

Finally Database Table where customer group price [$100.00] store

catalog_product_entity_tier_price

HNIGROUP ID = 4 as below Table

How To Create a Custom Console Command in Magento 2.x

There are following below steps to create custom console command or custom command to perform some complex data manipulation operation.

custom console command by using custom module

Here, we are considering as
Namespace / ModuleName = Mage2db/John

Magento 2 Custom Module

Step [1.1] – Create registration.php file under your module [ Namespace / ModuleName ]

File Path=Mage2db/John/registration.php

Add below content in this file.

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Mage2db_John',
    __DIR__
);

Step [1.2] – Create module.xml file under your module [ Namespace / ModuleName ]

File Path=Mage2db/John/etc/module.xml

Add below content in this file.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
    <module name="Mage2db_John" setup_version="1.0.0" />
</config>

Step [2] – Create di.xml file under your module etc directory. Add below content in this file.

File Path=Mage2db/John/etc/di.xml

<?xml version="1.0"?>

    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <type name="Magento\Framework\Console\CommandList">

       <arguments>

           <argument name="commands" xsi:type="array">

               <item name="Mage2dbHelloCustomer" xsi:type="object">Mage2db\John\Console\Hellocustomer</item>

           </argument>

       </arguments>

   </type>

</config>

Step [3] – Create Hellocustomer.php class file under your module Console directory. Add below code in this file.

File Path=Mage2db/John/Console/Hellocustomer.php

<?php
namespace Mage2db\John\Console;


use Symfony\Component\Console\Command\Command;

use Symfony\Component\Console\Input\InputInterface;

use Symfony\Component\Console\Output\OutputInterface;

 

class Hellocustomer extends Command

{

   protected function configure()

   {

       $this->setName('mage2db:hellocustomer');

       $this->setDescription('Demo Custom command line');

      

       parent::configure();

   }

   protected function execute(InputInterface $input, OutputInterface $output)

   {

    $output->writeln("Hello Customer,Custom Module For Custom Console Command");

   }

}

Step[4] – Finally, Custom module with Console Command has been done.

Run command

php bin/magento list

Once execute command, it is displaying custom command from list of all command as below.

mage2db:hellocustomer

Once execute command, mage2db:hellocustomer

php bin/magento mage2db:hellocustomer

Output will be as

Hello Customer, Custom Module For Custom Console Command

How To Create Events & Observer Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Preference Using Custom Module in Magento / Adobe Commerce 2.x


How To Create Plugin Using Custom Module in Magento / Adobe Commerce 2.x


How To Get Base URL in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Module in Magento 2.x / Adobe Commerce 2.x


How To Add Custom Block on Cart Page in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Log File in Magento 2.x / Adobe Commerce 2.x


How To Create Custom Controller in Magento 2.x / Adobe Commerce 2.x


How To Create a Custom Console Command in Magento 2.x / Adobe Commerce 2.x


How To Add Customer Groups Dropdown in Magento 2.x Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.


How To Get all Customers Data in Magento 2.x / Adobe Commerce 2.x


How To Set Tier Price With Percentage Value Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Tier Price Programmatically in Magento 2.x / Adobe Commerce 2.x


How To Add Websites Dropdown in Admin Form and Grid By UI Component in Magento 2.x / Adobe Commerce 2.x


Magento 2 All Database Tables [500 & more Tables]


How To Set Multi Shipping Settings In Magento 2


How To Set Origin Shipping in Magento 2


Difference Between Offline Shipping Method and Online Shipping Method


Magento 2 Online Customers Options



How To Apply Customer Group Price of Products in Magento 2


How To Add Customer Groups Dropdown in Magento 2 Admin Form and Grid By UI Component


How To Get all Customers Data in Magento 2


How To Create Customer Order in Magento 2 Admin Panel


Magento 2 Login As Customer Not Enabled


How To Configure Customer Account Sharing Options in Magento 2


Magento 2 Redirect To Customer Dashboard After Login


Which Magento 2 database table store customer shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 database table store customer’s Email Data


Which Magento 2 Database Table Store Customer Newsletter Data


Which Magento 2 database table store customer’s shipping and billing address


How To Remove Sales Order Data & Customer Data in Magento 2


Which Magento 2 Database Tables Store Customer Rating


Which Magento 2 Database Tables Store Customer Wishlist Products


Magento 2 Increase Customer Session Time


Which Magento 2 Database Table Store Patches

Magento 2.x Allowed memory size of XXXX bytes exhausted (tried to allocate XXXX bytes)

The cause of the error “allowed memory size of bytes exhausted” due to shortage of memory

There are following two type solution to resolve this issue

Solution [1] – Quick solution or Temporary solution

Add memory limit in the current running command

php -d memory_limit=-1 bin/magento deploy:mode:set developer
php -d memory_limit=-1 bin/magento setup:upgrade
php -d memory_limit=-1 bin/magento setup:di:compile
php -d memory_limit=-1 bin/magento setup:static-content:deploy -f
php -d memory_limit=-1 bin/magento indexer:reindex
php -d memory_limit=-1 bin/magento cache:clean
php -d memory_limit=-1 bin/magento cache:flush

Solution [2] – This is  Permanent solution.