I have a script that is creating a lot of configurable products and their associated simple products.
Everything goes ok and when inspecting the products in the admin section, everything is linked up and looks great.
The problem is that the products are not visible until I manually go to the admin section and save the configurable product - without changi开发者_StackOverflow社区ng any options - and then each simple product that is associated with it. After each simple product is saved, its option becomes available on the from end for the configurable product.
Does anyone have any ideas on this?
Solved this by going through the saveAction
in the Mage_Adminhtml_Catalog_ProductController
.
I wasn't setting the websiteIds correctly so the new products were never getting added to the site correctly.
Magento uses this piece of code to get the correct website:
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
Drew's answer above worked for me. For those using the REST API, this option is under extension_attributes like so:
"extension_attributes": {
"website_ids": [1]
}
Where 1 (for me) was the id of the website where I wanted the product to appear.
精彩评论