add - Adding magento product from frontend with attributes -
How to add products from the frontend with custom attributes? I have this code another stack question
// $ product = Dana :: MillModel ('catalog / product'); $ Product = new Mage_Catalog_Model_Product (); Echo time (); // Product $ Product- & gt; Set Attitissat ID (9); // # 4 default $ product- & gt; Create for Settype ID ('Simple'); $ Product- & gt; Setnam ('some good product names'); $ Product- & gt; Set descriptio ('full details here'); $ Product- & gt; Set Short Description ('Short description here'); $ Product- & gt; SetSku (time ()); $ Product- & gt; SetWeight (4.0000); $ Product- & gt; SetStatus (1); $ Product- & gt; Set Visibility (Mage_Catalog_Model_Product_Visibility :: VISIBILITY_BOTH); 4 print_r (Mage_Catalog_Model_Product_Visibility :: VISIBILITY_BOTH); $ Product- & gt; Setpiece (39.99); // # some value $ product- & gt; Settex classID (0); // # Set the default tax $ $ product- gt; Set StockData (array ('is_in_stock' => 1, 'Qty' => 99999)); $ Product- & gt; Set-sidelines (array (27)); // # some cat id, $ product-> gt; Set Websites (Ar (1)); // # website id, 1 default / default magenta attribute $ product- & gt; SetCreatedAt (strtotime ('now')); // print_r ($ product); Try {$ product- & gt; Save (); Echo "manufactured product"; } Hold (exception $ east) {// error "product creation fails" handle echo; } But I also have custom attributes, and how to add them to that code.
You need to call for each attribute:
$ Product- & gt; Setdata ('attribute_code_here', 'value here'); [/ edit] Yes / No Attributes is for:
$ Product - & gt; Set data ('attribute_code_here', 1); // 1 for yes, not for 0 for multiple selection
$ product-> Set data ('attribute_code_here', "4,6,12"); // Id of Comma Aligned values
Comments
Post a Comment