Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 以编程方式将所选内容添加到捆绑包_Php_Oop_Model View Controller_Zend Framework_Magento - Fatal编程技术网

Php 以编程方式将所选内容添加到捆绑包

Php 以编程方式将所选内容添加到捆绑包,php,oop,model-view-controller,zend-framework,magento,Php,Oop,Model View Controller,Zend Framework,Magento,关于进口,我想将进口产品作为捆绑产品添加到捆绑产品列表中 我扩展了Mage_Catalog_Model_Convert_Adapter_产品,并在自定义数据流中使用了此类,在保存导入的行之前,将执行以下代码: //Load product model collection filtered by attribute set id $products = Mage::getModel('catalog/product') ->getCollec

关于进口,我想将进口产品作为捆绑产品添加到捆绑产品列表中

我扩展了Mage_Catalog_Model_Convert_Adapter_产品,并在自定义数据流中使用了此类,在保存导入的行之前,将执行以下代码:

//Load product model collection filtered by attribute set id        
$products = Mage::getModel('catalog/product')
                ->getCollection()
                ->addAttributeToSelect('name')
                ->addFieldToFilter('attribute_set_id', 12);

// loop through products
foreach($products as $p){
    // get product options
    $options = $p->getTypeInstance(true)->getOptionsCollection($p);
}
接下来我需要做的是确定什么是正确的选项(按标题),并将产品作为选择添加到其中

$option->addSelection($selection);

但是,如何获取选项标题以及如何从我的产品中创建选择?

要获取选项标题,我执行了以下操作:

$option->getData('default_title');
要创建所选内容,我执行了以下操作:

$selection = new Mage_Bundle_Model_Selection();
$selection->addData(array(
'entity_id' => //bundle id,
'option_id' => $option->getId(),
'product_id' => //bundled item id,
'selection_price_value' => 0.00,
'selection_qty' => 1,
'selection_can_change_qty' => 0,
));

$selection->save();
$option->addSelection($selection);
$option->addData(array(
    'store_id' => 1,
    'title' => 'Abonnement'
));

 $option->save();
要将选择添加到选项,我执行了以下操作:

$selection = new Mage_Bundle_Model_Selection();
$selection->addData(array(
'entity_id' => //bundle id,
'option_id' => $option->getId(),
'product_id' => //bundled item id,
'selection_price_value' => 0.00,
'selection_qty' => 1,
'selection_can_change_qty' => 0,
));

$selection->save();
$option->addSelection($selection);
$option->addData(array(
    'store_id' => 1,
    'title' => 'Abonnement'
));

 $option->save();
我不知道为什么我必须设置标题和存储id,因为该选项已经存在,所以我认为它不必要,但如果我不这样做,我会得到一个“缺少存储id”或“缺少标题”错误

我喜欢Magento,但它很大,文档应该更好