php - Add selection to bundle programatically -


On import, I want to add imported products as bundled products in the list of bundled products.

I have extended the Mage_Catalog_Model_Convert_Adapter_Product and used this class in custom dataflows, the following code executes before saving the imported row:

  // Set filter products Load filtered model Model ID $ PRODUCTS: Mage :: getModel ('catalog / product') - & gt; GetCollection () - & gt; Add attitutes select ('name') - & gt; AddFieldToFilter ('attribute_set_id', 12); // Loop through product ($ P $ as products) {// Get product options $ option = $ p- & gt; GetTypeInstance (true) - & gt; GetOptionsCollection ($ p); }   

What I need to do next is to decide what is the correct option (according to the headline), and add the product as a selection.

  $ option & gt; AddSelection ($ selection);   

But how can I get the title of the choice and make selections from my product?

I did to get the option title:

  $ Option- & gt; GetData ('default_title');   

To create a selection I made:

  $ selection = New Mage_Bundle_Model_Selection (); $ Selection- & gt; Adyada (array ('entity_id' => = bundle id, 'option_id' => $ option-> getId (), 'product_id' = & gt; // bundle item id, 'selection_pres_view' = & Gt; 0.00, 'selection_qty' => 1, 'selection_can_change_qty' => 1,)); $ Selection- & gt; Save ();   

To add the option I chose:

  $ option-> addSelection ($ selection); $ Option- & gt; AdData (array ('store_id' = & gt; 1, 'title' = & gt; 'surrender')); $ Option & gt; Save ();   

I do not know why I want to set title and store_id, because the option already exists, so I think it should not be necessary, but if I do not Get the "missing store_id" or "missing title" error.

I like Magento but it is huge, the documentation should be better.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -