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

2
  • 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. Commented Sep 20, 2013 at 3:43
  • i edited the post with some code Commented Sep 20, 2013 at 3:51

1 Answer 1

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,

Sign up to request clarification or add additional context in comments.

3 Comments

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'); }
@user2797687,see oop rule stackoverflow.com/questions/1899299/…
@user2797687,i am sure my answer is sure help you and it would be glad for me if you will acept my answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.