I am working with Magento 2.0.10, I have created an observer to set the product price and weight posted from the products details page using a custom attribute. In the below example I am trying to set a static price and weight. For the price attribute its working correctly, but I am not able to set the weight. The quote item is giving the actual product weight while calculating shipping. Even if I change the observer event to sales_quote_item_set_product, it is not working at all for changing weight.
And even now I have tested with Magento 2.1 as well, but it isn't working at all
In events.xml and I am creating an observer like below
<event name="checkout_cart_product_add_after"> <observer name="checkout_cart_product_add_after_customprice" instance="Test\Slider\Observer\Customprice" /> </event>
And script that i have used in my observer is working like this
$item = $observer->getQuoteItem(); $item = ( $item->getParentItem() ? $item->getParentItem() : $item ); $item->setCustomPrice(10); $item->setOriginalCustomPrice(10); $item->setWeight(10); $item->getProduct()->setIsSuperMode(true);