在自定义模块中,使用我想要在Admin Grid中显示产品名称,在我的表中保存产品ID

i m尝试加入表

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

我得到了sku,但名称不显示如何获取名称

有帮助吗?

解决方案

使用加入,你必须获得这样的产品名称

$entityTypeId = Mage::getModel('eav/entity')
            ->setType('catalog_product')
            ->getTypeId();
    $prodNameAttrId = Mage::getModel('eav/entity_attribute')
        ->loadByCode($entityTypeId, 'name')
        ->getAttributeId();
    $collection->getSelect()
    ->joinLeft(
        array('prod' => 'catalog_product_entity'), 
        'prod.entity_id = main_table.mageproduct_id',
        array('sku')
    )
    ->joinLeft(
        array('cpev' => 'catalog_product_entity_varchar'), 
        'cpev.entity_id=prod.entity_id AND cpev.attribute_id='.$prodNameAttrId.'', 
        array('name' => 'value')
    ); 
.

这是对我的工作,希望这将帮助您

许可以下: CC-BY-SA归因
scroll top