Skip to content

Instantly share code, notes, and snippets.

@vishy93
Created February 26, 2019 14:30
Show Gist options
  • Save vishy93/443fd7eab1786ff6c9b01885a96044c3 to your computer and use it in GitHub Desktop.
Save vishy93/443fd7eab1786ff6c9b01885a96044c3 to your computer and use it in GitHub Desktop.
See by product id if product in category, if so which ones. Else not in any.
<?php
require '../app/Mage.php';
umask(0);
Mage::app('admin');
error_reporting(1);
set_time_limit(0);
ini_set('memory_limit', '2048M');
$productId = 11569;
$product = Mage::getModel('catalog/product')->load($productId);
$cats = $product->getCategoryIds();
foreach ($cats as $category_id) {
$_cat = Mage::getModel('catalog/category')->load($category_id) ;
if($_cat->getName()){
echo $category_id." => ".$_cat->getName()."</br>";
} else{
echo "not in";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment