Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To make a budle product you must set a prodtypeID to "bundle"</p> <p>this is code im using:</p> <pre><code> $__magproduct = new Mage_Catalog_Model_Product(); // Build the product $__magproduct-&gt;setSku(trim($sku_of_product)); $__magproduct-&gt;setAttributeSetId('4');# 4 is for default $__magproduct-&gt;setTypeId($prodtype); $__magproduct-&gt;setName($getprodId-&gt;ProductName); //$__magproduct-&gt;setCategoryIds(array(42)); # some cat id's, $__magproduct-&gt;setWebsiteIDs(array(1)); # Website id, 1 is default //$__magproduct-&gt;setDescription($getprodId-&gt;Description); //$__magproduct-&gt;setShortDescription($getprodId-&gt;Description); $__magproduct-&gt;setPrice($prodprice); # Set some price //Default Magento attribute $__magproduct-&gt;setWeight($getprodId-&gt;Weight); $__magproduct-&gt;setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH); $__magproduct-&gt;setStatus(1); $__magproduct-&gt;setTaxClassId(2); # default tax class $__magproduct-&gt;setCreatedAt(strtotime('now')); try { $__magproduct-&gt;save(); if (!($stockItem = $product-&gt;getStockItem())) { $stockItem = Mage::getModel('cataloginventory/stock_item'); $stockItem-&gt;assignProduct($__magproduct) -&gt;setData('stock_id', 1) -&gt;setData('store_id', 1); } $stockItem-&gt;setData('qty', $qty) -&gt;setData('is_in_stock', $isinstock) -&gt;setData('manage_stock', 1) -&gt;setData('use_config_manage_stock', 0) -&gt;save(); unset($__magproduct,$stockItem); </code></pre> <p>and after that insert a bundled options:</p> <pre><code>$productCheck = Mage::getModel('catalog/product')-&gt;loadByAttribute('sku',$getprodId-&gt;Code); Mage::register('product', $productCheck); $position = 0; $optionRawData = array(); $selectionRawData = array(); $selectionRawData[0] = array(); foreach ($materials as $material) { $material = (array) $material; $komponenta = $client-&gt;GetProductSimple($material["ProductID"]); $komponenta = (array) $komponenta; echo "&amp;nbsp;&amp;nbsp;&amp;nbsp;assigned: ".$komponenta["Code"]." ".$komponenta["ProductName"]." ks(".$material["Count"].")&lt;br&gt;\n"; $itemSKU = Mage::getModel('catalog/product')-&gt;getIdBySku(trim($getprodId-&gt;Code)); $materialSKU = Mage::getModel('catalog/product')-&gt;getIdBySku(trim($komponenta["Code"])); if (($itemSKU != "") &amp;&amp; ($materialSKU != "")) { $position++; $optionRawData[$position] = array( 'required' =&gt; 1, 'option_id' =&gt; '', 'position' =&gt; '', 'type' =&gt; 'radio', 'title' =&gt; 'Komponenta '.$komponenta["ProductName"], 'default_title' =&gt; 'Komponenta '.$komponenta["ProductName"], 'delete' =&gt; '', ); $selectionRawData[$position][] = array( 'product_id' =&gt; $materialSKU, 'selection_qty' =&gt; $material["Count"], 'selection_can_change_qty' =&gt; 0, 'position' =&gt; 0, 'is_default' =&gt; 1, 'selection_id' =&gt; '', 'selection_price_type' =&gt; 0, 'selection_price_value' =&gt; 0.0, 'option_id' =&gt; '', 'delete' =&gt; '' ); }; unset($material,$komponenta,$itemSKU,$materialSKU); }; Mage::register('productCheck', $productCheck); Mage::register('current_product', $productCheck); $productCheck-&gt;setCanSaveConfigurableAttributes(false); $productCheck-&gt;setCanSaveCustomOptions(true); // Set the Bundle Options &amp; Selection Data $productCheck-&gt;setBundleOptionsData($optionRawData); $productCheck-&gt;setBundleSelectionsData($selectionRawData); $productCheck-&gt;setCanSaveBundleSelections(true); $productCheck-&gt;setAffectBundleProductSelections(true); $productCheck-&gt;save(); </code></pre> <p><strong>Bunded item is not the same like Configurable!!</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload