Take the 2-minute tour ×

I've a list of product Ids and based on that product Id I want to get product Name but as the catalog_product_entity table doesn't contain the product name only sku, I'm trapped.

kindly check my code, I've tried left and right join both but not getting the name

        'entity_id = table_alias.product_id',

$result = null;

foreach ($collection as $temp) {    
    $result[] = array(
        'name' => $temp->getCustomer_name(),               
share|improve this question
if you want to get product name and you have product id so just load the product using product id and you get all product information –  Mufaddal Jul 13 '12 at 12:24
well let say I've 100 products I'll run 100 queries to get product name for each product, that's not a good way to run a query on for each product Id –  Muhammad Zubair Jul 13 '12 at 12:34
add comment

2 Answers

If you want your collection to load the product name, then the first part of your code is right. Here's a simplified version:


$result = array();

foreach ($collection as $temp) {
    $result[] = array('name' => $temp->getName());
share|improve this answer
sorry but I need the product Name acc to my_table, u missed the join –  Muhammad Zubair Jul 13 '12 at 13:45
It is unclear to me why you are joining an external table to get the product name. I am guessing it's not the default product name attribute provided by Magento but something else you have customized, am I right? Also in your code you are accessing an attribute called customer name, and not the actual product name. Feels that there is some information missing –  barbazul Jul 14 '12 at 16:46
No, actually I've saved the productId and customerId in myTable and now I want to show names of those productIds saved in the myTable so I'm joining it with catalog/product table –  Muhammad Zubair Jul 15 '12 at 6:46
add comment
up vote 0 down vote accepted

this is how I solved it

                $readResource    = $resource->getConnection('core_read');
                $tableName       = $resource->getTableName('myTable');

                $results = $readResource->select('table_alias.*')
                                'product_id = table_alias.entity_id',


                $dataList = array();

                foreach($products as $row)
                    $dataList[] = array('productName'=>$row['name'],'price'=> $row['price'],'status'=>$row['status'],'myTable_id'=>$row['myTable_id']);
share|improve this answer
add comment

Your Answer


