|
Hello,
I want to overwrite the function _getTypeId($type) in file app/code/core/Mage/Catalog/Model/Product/Link/Api.php.
At the moment that function looks as followed:
class Mage_Catalog_Model_Product_Link_Api extends Mage_Catalog_Model_Api_Resource { ... protected $_typeMap = array( 'related' => Mage_Catalog_Model_Product_Link::LINK_TYPE_RELATED, 'up_sell' => Mage_Catalog_Model_Product_Link::LINK_TYPE_UPSELL, 'cross_sell' => Mage_Catalog_Model_Product_Link::LINK_TYPE_CROSSSELL, ); ... protected function _getTypeId($type) { if (!isset($this->_typeMap[$type])) { $this->_fault('type_not_exists'); }
return $this->_typeMap[$type]; } ... }
I want to add an array-element ‘grouped’ to the $_typeMap variable so that it looks as follows:
protected $_typeMap = array( 'related' => Mage_Catalog_Model_Product_Link::LINK_TYPE_RELATED, 'up_sell' => Mage_Catalog_Model_Product_Link::LINK_TYPE_UPSELL, 'cross_sell' => Mage_Catalog_Model_Product_Link::LINK_TYPE_CROSSSELL, 'grouped' => Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED );
So far I’ve made my own module in app/code/community/Linux4ever/MagentoXtender/Model/Api.php that looks like this:
<?php
class Linux4ever_MagentoXtender_Model_Api extends Mage_Catalog_Model_Product_Link_Api //Mage_Core_Model_Abstract { /** OVERWRITE ARRAY IN BASE CLASS */ protected $_typeMap = array( 'related' => Mage_Catalog_Model_Product_Link::LINK_TYPE_RELATED, 'up_sell' => Mage_Catalog_Model_Product_Link::LINK_TYPE_UPSELL, 'cross_sell' => Mage_Catalog_Model_Product_Link::LINK_TYPE_CROSSSELL, 'grouped' => Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED ); /** OVERWRITE FUNCTION IN BASE CLASS */ protected function _getTypeId($type) { if (!isset($this->_typeMap[$type])) { $this->_fault('type_not_exists'); }
return $this->_typeMap[$type]; } }
?>
I’ve tried some things in app/code/community/Linux4ever/MagentoXtender/etc/config.xml like this:
<config> <global> <models> <Catalog_Product_Link_Api> <class>Linux4ever_MagentoXtender_Model</class> </Catalog_Product_Link_Api> </models> </global> </config>
But this doesn’t work.
How do I force Magento to use my class (Linux4ever_MagentoXtender_Model_Api) for all the catalog_product_link API Methods instead of Magento’s class(Mage_Catalog_Model_Product_Link_Api )?
|