Programatically added bundle product isn't showing up in frontend

后端 未结 2 1992
说谎
说谎 2020-12-28 23:13

I am trying to insert bundled products to the Magento database from a PHP script. The version in question is Community 1.5.1.0.

I tried the method described in the

2条回答
  •  猫巷女王i
    2020-12-29 00:00

    I have tried using your code, but it did not seem to work in Magento 1.7.0.2. Apparently the product could not be saved.

    What I did was added the following lines:

     Mage::register('product', $product);
     Mage::register('current_product', $product);
     $product->setCanSaveConfigurableAttributes(false);
     $product->setCanSaveCustomOptions(true);
    

    Just before the lines:

    // Set the Bundle Options & Selection Data
    $product->setBundleOptionsData($optionRawData);
    $product->setBundleSelectionsData($selectionRawData);
    $product->setCanSaveBundleSelections(true);
    $product->setAffectBundleProductSelections(true);
    
    $product->save();
    

    This seemed to fix the issue of not being able to save the file.

提交回复
热议问题