2

I have created a custom admin module using module creator with entity type "Flat" and it created 2 table in my database.

Now I need to insert product id in one of table when importing products from csv. Can anybody please help me to achieve this.

  • can anyone help me please? – Irphan khan Apr 2 '15 at 11:54
  • yes, i will help you – Amit Bera Apr 2 '15 at 12:14
  • Please let me know how I can do above mentioned task. – Irphan khan Apr 2 '15 at 12:23
0

You can do this by magento event/observer.

On catalog_product_save_after fire run observer which will work for admin section.

<adminhtml>
    <events>
      <catalog_product_save_after> <!-- identifier of the event we want to catch -->
        <observers>
          <catalog_product_save_after_handler> <!-- identifier of the event handler -->
            <type>singleton</type> <!-- class method call type; valid are model, object and singleton -->
            <class>magento62659/observer</class> <!-- observers class alias -->
            <method>fetchproductData</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to observer -->
          </catalog_product_save_after_handler>
        </observers>
      </catalog_product_save_after>
    </events>
</adminhtml>

and Observer code is like:

<?php
class Stackexchange_Magento62659_Model_Observer
{

    public function fetchproductData(Varien_Event_Observer $observer)
    {
        $product = $observer->getEvent()->getProduct();
        $action = Mage::app()->getFrontController()->getAction();
        if($action->getFullActionName()!='adminhtml_catalog_product_save'):
        $actin=$action->getFullActionName('-');
        Mage::log('+++'.$actin,null,'my.log');
        // do your code
        endif;

    }

}
| improve this answer | |
  • 1
    What is this $p you're logging? You also don't need the endif bit as you're in a class, it's all PHP, use brackets. – Julien Lachal Apr 26 '16 at 7:52
  • @Amit Bera, can you please help me with the same requirment for magento 2? – Sushivam Jul 30 '16 at 15:08
  • sure.i will help ... – Amit Bera Jul 30 '16 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.