After version 1.4.2.0, the methods loadParentProductIds() and getParentProductIds() are deprecated. Do not ask me why. Personally, I liked these methods. Therefore, I returned them to my local Mage classes. Here's how to do it: Copy
app/code/core/Mage/Catalog/Model/Product.php
to
app/code/local/Mage/Catalog/Model/Product.php
and change the loadParentProductIds() method found around line 1349 to:
public function loadParentProductIds() { return $this->_getResource()->getParentProductIds($this); }
This piece of code will request its resource for its parent product identifiers. To do this, we will need to rewrite the getParentProductIds() method in the resource class.
So copy:
app/code/core/Mage/Catalog/Model/Resource/Eav/Mysql4/Product.php
to
app/code/local/Mage/Catalog/Model/Resource/Eav/Mysql4/Product.php
Find the deprecated getParentProductIds() method. It should be somewhere near line 535. Overwrite it with code up to 1.4.2.0:
public function getParentProductIds($object){ $childId = $object->getId(); $groupedProductsTable = $this->getTable('catalog/product_link'); $groupedLinkTypeId = Mage_Catalog_Model_Product_Link::LINK_TYPE_GROUPED; $configurableProductsTable = $this->getTable('catalog/product_super_link'); $groupedSelect = $this->_getReadAdapter()->select() ->from(array('g'=>$groupedProductsTable), 'g.product_id') ->where("g.linked_product_id = ?", $childId) ->where("link_type_id = ?", $groupedLinkTypeId); $groupedIds = $this->_getReadAdapter()->fetchCol($groupedSelect); $configurableSelect = $this->_getReadAdapter()->select() ->from(array('c'=>$configurableProductsTable), 'c.parent_id') ->where("c.product_id = ?", $childId); $configurableIds = $this->_getReadAdapter()->fetchCol($configurableSelect); return array_merge($groupedIds, $configurableIds); }
Now you can do it again:
$_product->loadParentProductIds()->getData('parent_product_ids');
Hope this helps you!
source share