I am suffering from a wired problem with my Custom Module. maybe i have wrong logic in my mind or it's a problem. I created a custom module "PoProduct" to extend back-end functionality (\app\code\local\Company\Po) and i have a controller file which contains action like Save, Edit, Add etc.. Now, when i call this module into a external file and trigger save action, the controller function not called.

-------- External File Code Sample --------

$writeConnection = Mage::getSingleton('core/resource')->getConnection('core_write');
$readConnection = Mage::getSingleton('core/resource')->getConnection('core_read');

try {
    $product_Collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('status', 1);

    foreach ($product_Collection as $_product) {
        $po_product_Collection = Mage::getModel('po/poproduct')->getCollection()->addFieldToFilter('product_id', $_product->getId())->addFieldToFilter('stock_status', array("neq" => "deleted"));

        foreach ($po_product_Collection as $poproduct) {
} catch (Exception $ex) {}

Here, when calling $poproduct->save(); code it's not fire PoproductController.php saveAction().

-------- Custom Module Code Sample --------

  1. config.xml (\app\code\local\Company\Po\etc)

Code in config file

  1. Controller File (PoproductController.php in \app\code\local\Company\Po\controllers\Adminhtml)

    protected function _isAllowed() {
        return true;
    protected function _initAction() {
                ->_addBreadcrumb(Mage::helper('adminhtml')->__('Purchase Order Product'), Mage::helper('adminhtml')->__('Purchase Order Product'));
        return $this;
    public function indexAction() {
    public function saveAction() {
        if ($data = $this->getRequest()->getPost()) {            
            $model = Mage::getModel('po/poproduct');
            if ($id = $this->getRequest()->getParam('po_product_id')) {
            $model_poproduct = Mage::getModel('po/poproduct');
            try {
                $product_id = $model_poproduct->getProductId();
                $product = Mage::getModel("catalog/product")->load($product_id);
                Mage::getSingleton('core/session')->addSuccess(Mage::helper('po')->__('Product has been saved succesfully'));
            } catch (Exception $e) {


  • Save call model save not controller save
    – user52581
    Commented Apr 12, 2017 at 14:51
  • @Feedlay Technologies: Okay, It's wired for me. I am thinking its ->save() will call controller action. Can you please tell me which save method executed?
    – Ishan Jain
    Commented Apr 13, 2017 at 4:35

2 Answers 2


I can see you have called $product_id in controller file. Can you debug once on this. I assume $product_id = $model_poproduct->getProductId(); is not calling product model. please call product model as per your module.

  • Hmm, Accually i tried to mage log at the start of action function "public function saveAction()" i.e. first line of function is create a log file. But it's not creating log file to me.
    – Ishan Jain
    Commented Apr 13, 2017 at 13:55

Here Mage::getModel('po/poproduct')->getCollection() you are calling Model and executing the save function.
You are overwriting the controller where you need to overwrite the model file.
SaveAction() will be executed from the URL.

  • How can i execute this from URL?
    – Ishan Jain
    Commented Apr 13, 2017 at 13:52
  • Define proper routes to the url, it will be something like domainname.com/modulename/controllername/action Commented Apr 13, 2017 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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