Drew Hunter
Drew Hunter

Reputation: 10114

Magento - Configurable products not visible until manually saved in admin panel

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 changing 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?

Upvotes: 1

Views: 2989

Answers (2)

KatonahMike
KatonahMike

Reputation: 59

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.

Upvotes: 0

Drew Hunter
Drew Hunter

Reputation: 10114

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()));

Upvotes: 2

Related Questions