I want to check if product belongs to particular category then that product should be stored in that newly created category named folder.
I tried this code:
$productCollection = Mage::getResourceModel('catalog/product_collection')->addCategoryFilter($category);
$cats = $productCollection->getCategoryIds();
foreach ($cats as $category_id) {
$_cat = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($category_id);
$catname = $_cat->getName();
if (count(array_intersect($catname == 'Camera',$productCats))) {
$dispretionPath='/Camera';
} else {
$dispretionPath='/images' ;
}
}
--edit--
I tried this code but it is not creating folder
$product = Mage::getModel('catalog/product');
$cats = $product->getCategoryIds();
foreach ($product as $products) {
if (array_search($category_id == 3,$products) === false ) {
$dispretionPath='/Camera';
}else {
$dispretionPath='/images' ;
}
}
return $dispretionPath;
Any solution?