1

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?

Roman Snitko
  • 3,655
  • 24
  • 29
Drew Hunter
  • 10,136
  • 2
  • 40
  • 49
  • Is your script using magento code or putting products directly in the DB? – silvo Sep 12 '10 at 21:40
  • magento code - i have looked in the database and certain tables are not being populated until i have manually saved the each product in the admin area. for example the catalog_category_product_index table has nothing in it but after the product is manually saved data begins to populate it – Drew Hunter Sep 12 '10 at 21:45

2 Answers2

2

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()));
fkoessler
  • 6,932
  • 11
  • 60
  • 92
Drew Hunter
  • 10,136
  • 2
  • 40
  • 49
0

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.