I want to check if attribute value already exists programatically.
i created a unique attribute in magento say regnum , now i want to see if for any regnum value if there already exists product or not ,
can u please guide me how to do this ? i am bit new and can not figure out how to do it
Best Answer
Create a product Collection which give list products which have regnum fields
group this collection by grouByAttribute('regnum')
require '[Your_Magento_DIR]/app/Mage.php'; Mage::app("admin"); umask(0); $collection=Mage::getResourceModel('catalog/product_collection'); $collection->addAttributeToSelect('renum'); $collection->groupByAttribute('renum'); $renumValues=$collection->getColumnValues();