2

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

  • provide more info – Asish Hira Apr 21 '16 at 11:50
  • Asish, Am trying to update the "catalog_category_product" records for that i need to check whether record exit with "category_id" if exit need to update the record other wise add a new record – Allamsetti Apr 21 '16 at 11:52
  • using what?? using sql installer or using model ?? – Asish Hira Apr 21 '16 at 11:56
  • using Model like $model = Mage::getModel('test/test'); – Allamsetti Apr 21 '16 at 11:57
0
$_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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.