php - Function taking Comma separated values in variable as a single string -


i m trying filter product in product magento ce 1.7. im fetching values wanna filter multi dimensional array

foreach ($artist_productids $artist_productid){     $artist_product_id[] = $artist_productid['mageproductid']; } $artist_prodidstring = implode(',',$artist_product_id);  

and passing magento query

$categoryproducts = mage::getmodel('catalog/category')->load($currentartcat)  ->getproductcollection()  ->addattributetoselect('*') // add attributes - optional  ->addfieldtofilter('status', array('neq' => 2))  ->addattributetofilter('entity_id', array('nin' => array($artist_prodidstring))); 

while debugging fount passing value as

array('47,48,49,112,113,114,115,116') 

it should pass

array(47,48,49,112,113,114,115,116) 

how should solve !

why imploding array string , passing

$artist_prodidstring = implode(',',$artist_product_id);  

and using as

array('nin' => array($artist_prodidstring)); 

you can pass array directly as

 array('nin' => $artist_product_id); 

which u generated in foreach.

if $artist_product_id not proper array after

$artist_prodidstring = implode(',',$artist_product_id);  

make array using explode() , pass function.

you trying as

$str = '47,48,49,112,113,114,115,116' ; $array = array($str); print_r($array); output array (     [0] => 47,48,49,112,113,114,115,116 ) 

same happening in case numbers array key 0


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -