-3

I am eager to know how status of Product in Magento get changed/saved?

Requirement-:

Suppose there are existing products which are enabled in Magento...Now If admin Disable particular product from Backend then I need to catch that particular product's Id through code in Magento file system?

So from where Can I get disabled product's id in Magento code? What is the file location & function name for the same? how Can I get that particular id?

Please guide me...

Sam
  • 11
  • 2
  • how many questions will you ask on the same issue? – sulabh Jun 01 '12 at 13:04
  • I am not getting required answer....I need code location for the same in Magento?? – Sam Jun 01 '12 at 13:10
  • 1
    Sam, you are obviously new here. You should google this prior to asking them on here. Also try to ask one specific question not a multitude of questions. – Gershon Herczeg Jun 01 '12 at 13:50
  • possible duplicate of [Where is Magento code location to disable products?](http://stackoverflow.com/questions/10847929/where-is-magento-code-location-to-disable-products) – Stephen C Jun 02 '12 at 03:23

1 Answers1

2

I think the down voting here is a bit unfair. The op is only asking one question - how to get the product id and status of a product after it has been saved.

@Sam - in Magento, instead of finding the exact point in code where a product is being saved, you would typically hook into an event by creating a custom module and use the Magento event/observer facility from within that module.

Have a look through this tutorial which will guide you through the process of creating a module with event/observers: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method

Specifically related to your question: the event you are looking for is catalog_product_save_after.

The xml for your event would look similar to this:

<events>
  <catalog_product_save_after>
    <observers>
      <yourmodule>
        <class>Yourcompany_Yourmodule_Model_Observer</class>
        <method>catalog_product_save_after</method>
      </yourmodule>
    </observers>
  </catalog_product_save_after>     
</events>

Your observer is going to look similar to this:

class Yourcompany_Yourmodule_Model_Observer 
{
    public function catalog_product_save_after($observer)
    {
        $product = $obvserver->getEvent()->getProduct();

        $productStatus = $product->getStatus();
        $productId = $product->getId();
    }
}

Note - code is untested

Drew Hunter
  • 10,136
  • 2
  • 40
  • 49
  • 1
    The down voting is justified. Asking the same question again on SO is a behaviour that the community views as unacceptable. If the OP is not happy with the answers he got, he should should EDIT his original question. – Stephen C Jun 02 '12 at 03:27