almost 11 years ago
we can create products with custom options by programming in Magento follow the steps :
Post all details to form controller to save product
public function saveproductAction() { $param = $this->getRequest()->getPost(); $categoryId = $_REQUEST['catId']; $productName = $_REQUEST['ProductName']; $productDesc = $_REQUEST['productDesc']; $productPrice = $_REQUEST['productPrice']; $productQty = $_REQUEST['productQty']; $options = array(); $option = array(); for($i=0;$i"; $options[$j]['title'] = $param['choicetitle'][$i][$j]['title']; $options[$j]['price'] = $param['choicetitle'][$i][$j]['price']; $options[$j]['price_type'] = 'fixed'; $options[$j]['sort_order'] = '1'; } $option[$i]['title'] = $param['choicetitle'][$i]['choice'];//adding no of choices $option[$i]['type'] = $param['choicetype'][$i]['type']; $option[$i]['is_require'] = 0; $option[$i]['sort_order'] = $i; $option[$i]['values'] = $options; } $newproduct = new Mage_Catalog_Model_Product(); $newproduct->setTypeId('simple'); $newproduct->setWeight(10); $newproduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH); $newproduct->setStatus(1); $newproduct->setSku($productName.time()); $newproduct->setTaxClassId(2); $newproduct->setCategoryIds($categoryId); $newproduct->setWebsiteIDs(array(1)); //$newproduct->setStoreIDs(array(1)); $newproduct->setStockData(array( 'is_in_stock' => 1, 'qty' =>$productQty, 'manage_stock' => 1 )); $newproduct->setAttributeSetId(4); $newproduct->setName($productName); $newproduct->setDescription($productDesc); $newproduct->setShortDescription($productDesc); $newproduct->setPrice($productPrice); $newproduct->setProductOptions($option); $newproduct->setCanSaveCustomOptions(true); try{ $newproduct->save(); //echo "Success"; $this->_redirect('manager/account/dashboardedit/'); } catch (Exception $e){ echo $e->getMessage(); } }
By using this code we can add SELECT, CHECKBOX, RADIO type options to product
Starting with Chrome version 45, NPAPI is no longer supported for Google Chrome. For more information, see Chrome and NPAPI (blog.chromium.org).
Firefox and Microsoft Internet Explorer are recommended browsers for websites using java applets.
Chrome Version Support
Are you sure, you want to delete this comment?
Sign up using
0 Comment(s)