0

is it possible in magento php to invoke the method from parent class rather than from the overridden one,

I have extension overrides (A_CustomOptions_Model_Catalog_Product_Option extends Mage_Catalog_Model_Product_Option) and it overrides the construct method and I have got another extension wants to use the construct of parent class Mage_Catalog_Model_Product_Option

is there a way to do this???

more explanation:

class A_CustomOptions_Model_Catalog_Product_Option extends Mage_Catalog_Model_Product_Option {

  protected function _construct() {
      parent::_construct();
      $this->_init('customoptions/product_option');       
  }
}

in another extension i'm getting collection for options

public function getOptions($srcId) {

   $options = Mage::getModel('catalog/product_option')
     ->getCollection()
     ->addTitleToResult(Mage::app()->getStore()->getId())
     ->addPriceToResult(Mage::app()->getStore()->getId())
     ->addProductToFilter($srcId)
     ->addValuesToResult();

   return $options;
}  

however because this parent class Mage_Catalog_Model_Product_Option is overridden, it doesn't return me the parent options not overridden ones Thanks

Dave Stein
  • 8,653
  • 13
  • 56
  • 104
Alan
  • 75
  • 1
  • 2
  • 12
  • Can you put some of your code in? I'm pretty sure you are asking for `parent::__construct();` but the wording is a little unclear so I might be missing something. – Dave Stein Sep 20 '13 at 03:43
  • i edited the post with some code – Alan Sep 20 '13 at 03:51

1 Answers1

0

yes you can call parent constructor with use of below code

class A_CustomOptions_Model_Catalog_Product_Option extends Mage_Catalog_Model_Product_Option
{
   public function __construct()
    {

        parent::__construct();
    }
}

As your updated answer i think override class loaded at the last that might be not work.

hope this will sure work for you in simple OOP concept,

liyakat
  • 11,825
  • 2
  • 40
  • 46
  • I can't remove the rest statements after parent::__construct(); in overridden class the method should be protected function _construct() { parent::_construct(); $this->_init('customoptions/product_option'); } – Alan Sep 20 '13 at 04:24
  • @user2797687,see oop rule http://stackoverflow.com/questions/1899299/phpoop-how-to-call-class-constructor-manually – liyakat Sep 20 '13 at 04:28
  • @user2797687,i am sure my answer is sure help you and it would be glad for me if you will acept my answer – liyakat Sep 21 '13 at 09:30