Domanda

In Modulo personalizzato I M salvataggio ID prodotto nella mia tabella usando che voglio visualizzare il nome del prodotto in Grid admin

Sto provando questo codice a unire il tavolo

$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')
    ); 
.

Sto ottenendo Sku ma il nome non è visualizzato come ottenere il nome

È stato utile?

Soluzione

Utilizzo Inizio U devi ottenere il nome del prodotto come questo

$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')
    ); 
.

Questo è lavorato per me spero che questo ti aiuterà

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top