Magento - how do I get associated products of product Group?

后端 未结 3 770
灰色年华
灰色年华 2021-01-31 11:55

I am looping through products results, and if the product is a grouped product, I want to get all products in that group. I\'m doing this:

$products = Mage::getM         


        
3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-31 12:49

    Or if you want just to get ids of associated products, you can use the following method (it is much faster):

    public function getAssociatedProductIds($groupedProductId)
    {
        $coreResource = Mage::getSingleton('core/resource');
        $conn = $coreResource->getConnection('core_read');
        $select = $conn->select()
            ->from($coreResource->getTableName('catalog/product_relation'), array('child_id'))
            ->where('parent_id = ?', $groupedProductId);
    
        return $conn->fetchCol($select);
    }
    

提交回复
热议问题