Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Programatically create products in Magento

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 302
    Comment on it
    public function saveproductAction()
     { 
        $categoryId    =   $_REQUEST['catId'];
        $productName   =   $_REQUEST['ProductName'];
        $productDesc   =   $_REQUEST['productDesc'];
        $productPrice  =   $_REQUEST['productPrice'];
        $productQty    =   $_REQUEST['productQty'];
        $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(0);
            $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($data['description']);
            $newproduct->setShortDescription($productDesc);
            $newproduct->setPrice($productPrice);
            try{
            $newproduct->save();
            //echo "Success";
            $this->_redirect('manager/account/dashboardedit/');
            }
            catch (Exception $e){
            echo $e->getMessage();
          }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: