当前位置: 动力学知识库 > 问答 > 编程问答 >

Magento multiversion module Error class Mage_Catalog_Model_Resource_Product_Option not found

问题描述:

I'm trying to create module for magento. It use my own class

class Myfirm_Extname_Model_Mysql4_Product_Option extends Mage_Catalog_Model_Resource_Product_Option

In magento 1.7 all works fine, in 1.5 - error: Error class Mage_Catalog_Model_Resource_Product_Option not found.

How can I make class that will be inherited from Mage_Catalog_Model_Resource_Product_Option or Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Option depending on the version of magento?

网友答案:

I solved this prodblem.

protected function _getResource() {
       if (version_compare(Mage::getVersion(), '1.6.0', '<')) {
            $this->_resourceName = $this->_resourceName.'_oldversion';
        }
        if (empty($this->_resourceName)) {
            Mage::throwException(Mage::helper('core')->__('Resource is not set.'));
        }

        return Mage::getResourceSingleton($this->_resourceName);
    }

And then create 2 resource model class for old version of magento and new

分享给朋友:
您可能感兴趣的文章:
随机阅读: