php - Export products with Category Names -


i'm exporting categories associated product array. it's working fine static indexes follow:

foreach($collection $product) {     $_cat = array();     $categoryname = array();         foreach ($product->getcategoryids() $id) {         $_cat = mage::getmodel('catalog/category')->setstoreid(mage::app()->getstore()->getid())->load($id);         $categoryname[] = $_cat->getname();     }     fputcsv(         $output,          array(             $categoryname[0] . $categoryname[1] . $categoryname[2]         )     ); } 

when i'm trying give indexes dynamically using foreach() or for() loop, products not being exported. example, if i'm using

fputcsv(     $output,      array(         foreach($categoryname $name) {              echo $name;         }     ) ); 

it's not working.

also i've tried

fputcsv($output,      array(         array_value($categoryname);     ) ); 

but prints output array whereas i'm looking array values output.

you can use implode() prepare array values needs.

http://php.net/manual/en/function.implode.php


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -