简体   繁体   English

在magento中,使用父类中的方法而不是重写类

[英]in magento use the method from parent class not the overriden class

is it possible in magento php to invoke the method from parent class rather than from the overridden one, 在magento php中是否有可能从父类而不是被覆盖的类中调用该方法,

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 我有扩展覆盖(A_CustomOptions_Model_Catalog_Product_Option扩展了Mage_Catalog_Model_Product_Option),并且它覆盖了构造方法,我还有另一个扩展要使用父类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 但是,因为此父类Mage_Catalog_Model_Product_Option被覆盖,所以它不会返回我未覆盖的父选项。

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, 希望这一定会为您带来简单的OOP概念,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM