0

Here is my partial code

    $productObj = $objectManager->create('Magento\Catalog\Model\Product');
        $totalAdded ++;
        $productObj->setName($value->product_name) // Use default        
        // ->setStoreId(39)
           ->setPrice(100.99) 
            // price in form 100.99

        ->setAttributeSetId(9) //ID of a attribute set named 'default'
        ->setStatus($var_val->status)
        ->setVisibility(4)
        ->setStoreId($storeId)
        ->setWebsiteIds(array($websiteId))
        ->setDescription($value->description)

        //->setSpecialPrice($var_val->min_price) //special price in form 11.22
        ->setSku($var_val->sku."-".$var_val->variant_id) //SKU        
      ->setStockData(array(
            'use_config_manage_stock' => 0, //'Use config settings' checkbox
            'manage_stock'=>1, //manage stock
            'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
            'max_sale_qty'=>2, 
             //Maximum Qty Allowed in Shopping Cart
            'is_in_stock' => 1, //Stock Availability
            'qty' => $var_val->quantity //qty
        ))       

        ->setColor($var_val->color)
        ->setWeight($var_val->weight);

after adding product price is not getting stored in backend and showing 0 in frontend.

1 Answer 1

0

Please use setFinalPrice(100.99) instead of setPrice(100.99).

I hope this will help you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.