Php 以编程方式添加的捆绑产品未显示在fronend、magento问题中

Php 以编程方式添加的捆绑产品未显示在fronend、magento问题中,php,magento,csv,Php,Magento,Csv,我通过从CSV获取数据添加了捆绑产品。以这种方式添加的产品在管理面板中可见,但在前端不可见。我经历了所有的问题,但没有找到解决办法。请帮我解决这个问题 require_once($magentoPath . 'includes/config.php'); require_once($magentoPath . 'app/Mage.php'); $storeID = 1; $websiteIDs = array(1); $cats = array("12"); Mage::a

我通过从CSV获取数据添加了捆绑产品。以这种方式添加的产品在管理面板中可见,但在前端不可见。我经历了所有的问题,但没有找到解决办法。请帮我解决这个问题

require_once($magentoPath . 'includes/config.php');
  require_once($magentoPath . 'app/Mage.php');
  $storeID = 1;
  $websiteIDs = array(1);
  $cats = array("12");

  Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

  $productCheck = Mage::getModel('catalog/product');

  $p = array(
    'sku_type' => 0,
    'sku' => '687',
    'name' => "BarProduct",
    'description' => 'Foo',
    'short_description' => 'Bar',
    'type_id' => 'bundle',
    'attribute_set_id' => 4,
    'weight_type' => 0,
    'visibility' => 4,
    'price_type' => 0,
    'price_view' => 0,
    'status' => 1,
    'created_at' => strtotime('now'),
    'category_ids' => $cats,
    'store_id' => $storeID,
    'website_ids' => $websiteIDs
  );

  $productCheck->setData($p);
  Mage::register('product', $product);
  $optionRawData = array();
  $optionRawData[0] = array(
    'required' => 1,
    'option_id' => '',
    'position' => 0,
    'type' => 'select',
    'title' => 'FooOption',
    'default_title' => 'FooOption',
    'delete' => '',
  );

  $selectionRawData = array();
  $selectionRawData[0] = array();
  $selectionRawData[0][] = array(
    'product_id' => 337,
    'selection_qty' => 1,
    'selection_can_change_qty' => 1,
    'position' => 0,
    'is_default' => 1,
    'selection_id' => '',
    'selection_price_type' => 0,
    'selection_price_value' => 0.0,
    'option_id' => '',
    'delete' => ''
  );
Mage::register('productCheck', $productCheck);
 Mage::register('current_product', $productCheck);
 $productCheck->setCanSaveConfigurableAttributes(false);
 $productCheck->setCanSaveCustomOptions(true);
  // Set the Bundle Options & Selection Data
  $productCheck->setBundleOptionsData($optionRawData);
  $productCheck->setBundleSelectionsData($selectionRawData);
  $productCheck->setCanSaveBundleSelections(true);
  $productCheck->setAffectBundleProductSelections(true);

  $productCheck->save();
  $indexer = Mage::getSingleton('index/indexer');
foreach ($indexer->getProcessesCollection() as $process) {
    $process->reindexAll();
}
  • 请注意,只要我通过管理面板重新保存我的产品,它就会开始显示在前端


Mage::register('product',$product)=>
Mage::register('product',$productCheck)

非常感谢亲爱的,还有一个问题,产品缺货。要使其有库存:$productCheck->setStockData(数组('is_in_stock'=>1,'qty'=>12));