Ask your Question



jr. php developer

bhopal,  India

muzffarpur,  India

Chiplun,  India
Everest Educational
Everest Educational

Visa Consultants in Punjab

Ludhiana,  India

Web developer

Gurgaon,  India

Write to us

Ask Question

Indexing through Command line Magento1.x

Reindexing in Magento1.X through Command line:

Sometimes we need to re-index Magento through command line to avoid the broken process from Magento Interface.

On our Magento root folder we have shell directory that contains indexing script

... Read More

Show error message when adding a product of price 0.

To restrict products having price zero from shopping we need to create a observer on
checkout_cart_product_add_after event such that on every add to cart it will check the
product price and then add to cart.

... Read More

Admin and Frontend icon fonts missing after installing Magento2.O

Admin and Frontend icon fonts missing after installing Magento2.O

Admin and Frontend icon fonts missing after installing Magento2.O

... Read More

How to delete a product in Magento2 Programatically

How to delete a product in Magento2 Programatically

 To delete a product from frontend 

1. On delete icon/link we need to pass the product ID which we need to delete.
2. We need to create a  controller class to execute the delete process and
  need to write the delete code under execute method of class.
 class Deleteproduct extends MagentoFrameworkAppActionAction
    protected $_productRepositoryInterface;
public function __construct(
          MagentoFrameworkAppActionContext $context,
          MagentoCatalogModelProductRepository $productRepository,
          MagentoFrameworkRegistry $registry)
        $this->productRepository = $productRepository;
        $this->registry = $registry;
     public function execute()
    $productInfo = $this->getRequest()->getParams();
    $productID  = $productInfo['id'];
    $this->registry->register('isSecureArea', true);
    $product = $this->productRepository->getById($productID);
    $this->messageManager->addSuccess(  __('Product has been deleted!') );
... Read More

Magento Events and Observers

 To separate your custom code from the core code we use event driven programming where an event is fired and an observer is listening for specific events and executing certain logics on specific event. These events have certain class objects attached as function parameter .Observers (Class functions) runs when the event is fired and receive the class objects. The observer manipulates and receives data from class objects (event) and performs the operation on data according to requirement.

To create some observer on a specific event we need to create our own module and

event in config.xml of the module as below.

We will define the event under events tags in config.xml and under observer tag we need to define the name of the method call after event fire

Suppose we need send an custom email after every successful order, then we


Need to call the observer on checkout_onepage_controller_sucess_action and we have to define it in config.xml file of our module.

File: app/code/local/Letsknowit/Checkout/etc/config.xml <global>
      <checkout_onepage_controller_success_action>   //Event Name
          <sendcustomemail>   //Name of observer



Now in our custom module we need to define our observer function in Observer.php


File: app/code/local/Letsknowit/Checkout/Model/Observer.php class Letsknowit_Postdata_Model_Checkout_Observer


public function sendcustomemail(Varien_Event_Observer $observer){




After every successful order the observer function call and will do the required functionality


... Read More

Please rotate your device

We don't support landscape mode on your device. Please rotate to portrait mode for the best view of our site