2

In Magento 1.9, I Have a custom admin grid.

I have product id in my custom collection. I need to add product name to that collection. How to achieve it?

I am using the following code.

$productTable = Mage::getSingleton('core/resource')->getTableName('catalog/product');
$orders->getSelect()->join( array('product_data'=> $productTable),
'product_data.entity_id = main_table.product_id',
array('product_data.name'));
2

You can try this code:

// Get Attribute Id for name attribute
$entityTypeId = 
Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
$prodNameAttrId = Mage::getModel('eav/entity_attribute')
->loadByCode($entityTypeId, 'name')->getAttributeId();

/*
* Join Product SKU and Name into the OrderCollection - Change
collection as per your need
*/

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

Refer this link

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.