Need help making a query which returns the Product ID of all products which have custom options

  • You want a SQL query direct from the database or through Magento? – brentwpeterson Jan 14 '15 at 21:43


$options = Mage::getModel('catalog/product_option')->getCollection();

foreach ($options as $option) {


SELECT DISTINCT `main_table`.`product_id` FROM `catalog_product_option` AS `main_table`
  • 1
    you can add a Distinct also in the select to remove duplicates. – Marius Jan 14 '15 at 21:37
  • This worked great. Curious if you could advise how to make the query more elaborate so it returns all product id AND product name AND what custom options are available for that product. Thank you!! – Craig Tommola Jan 26 '15 at 15:27

Hi please use the below query

    echo  $Sql= Mage::getModel('catalog/product_option')->getCollection()
-> addFieldToSelect('product_id')->getSelect()

echo $Sql->__toString();

use getSelect() function for getting the sql query and distinct to get distinct data

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.