Magento – How to check if value exists in catalog_category_product table Magento

databasemagento2query

How can I check if the value exists in catalog_category_product table Magento ?

Best Answer

$_product = Mage::getModel('catalog/product')->load(product_id);
$categoryIds = $_products->getCategoryIds();
if(in_array(category_id, $categoryIds)){
 echo "value already there!";
}
else
{
echo "value not there!";
}

Hope this will work for you.

Related Topic