Hi I am developing a script which makes simple products for magento store. I have added the products through the script but now I want to add custom options to the added simple product. How would I do it through my custom script? Here is how I am adding the product:

$product = Mage::getModel('catalog/product');
        ->setStoreId($store_id) //you can set data in store scope
        ->setWebsiteIds(array(1)) //website ID the product is assigned to, as an array
        ->setAttributeSetId(4) //ID of a attribute set named 'default'
        ->setTypeId('simple') //product type
        ->setCreatedAt(strtotime('now')) //product creation time
        ->setStatus(1) //product status (1 - enabled, 2 - disabled)
        ->setTaxClassId(0) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
        ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH) //catalog and search visibility

After this code I want to add the custom options to this added product. How can I do it? Any help would be greatly appreciated. Thankyou.

  • Have you tried my suggestion?
    – laketuna
    Commented Mar 19, 2015 at 13:37

2 Answers 2


Before $product->save(), you can add some code to save. Here's some good guides on how it works and what you need to write. HERE and HERE


$options = array(...); // Look at guides how to create this array

Magento provides SOAP API for this. You should use magento SOAP API for add product which is secure and standard method of Magento. For add custom option you can use following API:


It has example with explanation of API uses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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