1

May be this question was already asked..But I didn't like the answers. I wanna to join the product Name starting from my custom resource collection. My custom resource collection has a field called product_id. How can I do this ?

4

1 回答 1

3

首先将产品实体集合加入您的自定义集合(我想通过 product_id),然后将产品名称加入它,如下所示:

$collection 是您的自定义集合对象,例如: $collection = Mage::getResourceModel('custom/model_collection');

$prodNameAttrId = Mage::getModel('eav/entity_attribute')
->loadByCode('4', 'name')
->getAttributeId();

$collection->getSelect()
->joinLeft(
    array('prod' => 'catalog_product_entity'), 
    'prod.entity_id = main_table.product_id',
    array('sku')
)
->joinLeft(
    array('cpev' => 'catalog_product_entity_varchar'), 
    'cpev.entity_id = prod.entity_id AND cpev.attribute_id='.$prodNameAttrId.'', 
    array('name' => 'value')
);

把这个写出来,但这至少应该让你开始。祝您好运!

于 2013-06-25T13:59:27.840 回答