Jump to content

Loop Array


Tufanayd

Recommended Posts

Hi,

 

I am not very good at PHP however I am trying to edit a php function for Magento.

$categoryID = $this->getCategoryId(); //the value is like 7,3,6,9
$cats = explode(',', $categoryID);

$collection = Mage::getModel('catalog/product')
    ->getCollection()
    ->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left')
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('category_id', array(
        array('finset' => '7'),
        array('finset' => '3'),
        array('finset' => '6'),
        array('finset' => '9')
        )
        );

I want to generate the below part automatically based on the value(s) of $cats

 

array('finset' => '7'),
array('finset' => '3'),

array('finset' => '6'),

array('finset' => '9')

 

How can I do it, urgent help will be extremely appreciated.

 

Thanks in advance

 

Link to comment
https://forums.phpfreaks.com/topic/280987-loop-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.