Magento 2 checkout_cart_product_add_after Observer setWeight not working Planned maintenance...

Why was the term "discrete" used in discrete logarithm?

Is it true that "carbohydrates are of no use for the basal metabolic need"?

Can I cast Passwall to drop an enemy into a 20-foot pit?

How to find all the available tools in mac terminal?

Do I really need recursive chmod to restrict access to a folder?

Short Story with Cinderella as a Voo-doo Witch

What does F' and F" mean?

Why didn't this character "real die" when they blew their stack out in Altered Carbon?

What's the meaning of 間時肆拾貳 at a car parking sign

porting install scripts : can rpm replace apt?

Should I use a zero-interest credit card for a large one-time purchase?

List *all* the tuples!

How to answer "Have you ever been terminated?"

Can a non-EU citizen traveling with me come with me through the EU passport line?

Why are both D and D# fitting into my E minor key?

Why aren't air breathing engines used as small first stages

When were vectors invented?

How do I keep my slimes from escaping their pens?

In predicate logic, does existential quantification (∃) include universal quantification (∀), i.e. can 'some' imply 'all'?

Why are Kinder Surprise Eggs illegal in the USA?

Why did the Falcon Heavy center core fall off the ASDS OCISLY barge?

How can I make names more distinctive without making them longer?

Can an alien society believe that their star system is the universe?

3 doors, three guards, one stone



Magento 2 checkout_cart_product_add_after Observer setWeight not working



Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Set custom price of product when adding to cart code not workingMagento2 adminhtml_catalog_product_grid_prepare_massaction event is not observedMagento 2 catalog_product_get_final_price event not working for configurable productMagento 2 - Category Save Event is not called when save category via rest apiMagento 2 Enterprise edition, get all custom attributes of product in the observerSet Name of quote_itemMagento-2 : How to set product custom price after add to cartMagento 2 catalog_product_get_final_price event not workingAdd event after user add the product to cart to update quantityMagento 2 controller_action_predispatch observer not working as expected





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2















I am working with magento 2.0.10 , I have created an observer to set product price and weight posted from products details page using custom attribute. In the below example i am trying to set static price and weight. But for price attribute its working correct , but not able to set weight , the quote item is giving actual product weight while calculating shipping. Even if i change the observer event to sales_quote_item_set_product not working at all for changing weight.



And even now i have tested with magento 2.1 as well. Not working at all



In events.xml and I am creating observer like below



<event name="checkout_cart_product_add_after">
<observer name="checkout_cart_product_add_after_customprice" instance="TestSliderObserverCustomprice" />
</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);









share|improve this question
















bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • It would be saving under field row_weight, not sure why but if you can adjust to use it at required places by using $item->getRowWeight() in your calculations..

    – Himmat Paliwal
    Nov 2 '18 at 6:35




















2















I am working with magento 2.0.10 , I have created an observer to set product price and weight posted from products details page using custom attribute. In the below example i am trying to set static price and weight. But for price attribute its working correct , but not able to set weight , the quote item is giving actual product weight while calculating shipping. Even if i change the observer event to sales_quote_item_set_product not working at all for changing weight.



And even now i have tested with magento 2.1 as well. Not working at all



In events.xml and I am creating observer like below



<event name="checkout_cart_product_add_after">
<observer name="checkout_cart_product_add_after_customprice" instance="TestSliderObserverCustomprice" />
</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);









share|improve this question
















bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • It would be saving under field row_weight, not sure why but if you can adjust to use it at required places by using $item->getRowWeight() in your calculations..

    – Himmat Paliwal
    Nov 2 '18 at 6:35
















2












2








2








I am working with magento 2.0.10 , I have created an observer to set product price and weight posted from products details page using custom attribute. In the below example i am trying to set static price and weight. But for price attribute its working correct , but not able to set weight , the quote item is giving actual product weight while calculating shipping. Even if i change the observer event to sales_quote_item_set_product not working at all for changing weight.



And even now i have tested with magento 2.1 as well. Not working at all



In events.xml and I am creating observer like below



<event name="checkout_cart_product_add_after">
<observer name="checkout_cart_product_add_after_customprice" instance="TestSliderObserverCustomprice" />
</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);









share|improve this question
















I am working with magento 2.0.10 , I have created an observer to set product price and weight posted from products details page using custom attribute. In the below example i am trying to set static price and weight. But for price attribute its working correct , but not able to set weight , the quote item is giving actual product weight while calculating shipping. Even if i change the observer event to sales_quote_item_set_product not working at all for changing weight.



And even now i have tested with magento 2.1 as well. Not working at all



In events.xml and I am creating observer like below



<event name="checkout_cart_product_add_after">
<observer name="checkout_cart_product_add_after_customprice" instance="TestSliderObserverCustomprice" />
</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);






magento2 magento-2.1 magento-2.0






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 18 '16 at 12:33







Dinesh Saini

















asked Nov 14 '16 at 13:45









Dinesh SainiDinesh Saini

400217




400217





bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 12 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • It would be saving under field row_weight, not sure why but if you can adjust to use it at required places by using $item->getRowWeight() in your calculations..

    – Himmat Paliwal
    Nov 2 '18 at 6:35





















  • It would be saving under field row_weight, not sure why but if you can adjust to use it at required places by using $item->getRowWeight() in your calculations..

    – Himmat Paliwal
    Nov 2 '18 at 6:35



















It would be saving under field row_weight, not sure why but if you can adjust to use it at required places by using $item->getRowWeight() in your calculations..

– Himmat Paliwal
Nov 2 '18 at 6:35







It would be saving under field row_weight, not sure why but if you can adjust to use it at required places by using $item->getRowWeight() in your calculations..

– Himmat Paliwal
Nov 2 '18 at 6:35












1 Answer
1






active

oldest

votes


















0














Finally , i have found the solution. May be it's not the best solution , but it works



I have just commented line number 422 with script



->setWeight($this->getProduct()->getWeight()) 


coming inside setProduct function in the below file



/vendor/magento/module-quote/Model/Quote/Item.php


And its working for me.






share|improve this answer
























  • You know that changing code in a file that's in vendor will be overwritten as soon as a newer version of that file/module is available and installed. I have to be honest, I don't know the answer right away, but I don't think this will be the solution you're looking for.

    – Arjen Miedema
    Feb 27 '18 at 6:24












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f145662%2fmagento-2-checkout-cart-product-add-after-observer-setweight-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Finally , i have found the solution. May be it's not the best solution , but it works



I have just commented line number 422 with script



->setWeight($this->getProduct()->getWeight()) 


coming inside setProduct function in the below file



/vendor/magento/module-quote/Model/Quote/Item.php


And its working for me.






share|improve this answer
























  • You know that changing code in a file that's in vendor will be overwritten as soon as a newer version of that file/module is available and installed. I have to be honest, I don't know the answer right away, but I don't think this will be the solution you're looking for.

    – Arjen Miedema
    Feb 27 '18 at 6:24
















0














Finally , i have found the solution. May be it's not the best solution , but it works



I have just commented line number 422 with script



->setWeight($this->getProduct()->getWeight()) 


coming inside setProduct function in the below file



/vendor/magento/module-quote/Model/Quote/Item.php


And its working for me.






share|improve this answer
























  • You know that changing code in a file that's in vendor will be overwritten as soon as a newer version of that file/module is available and installed. I have to be honest, I don't know the answer right away, but I don't think this will be the solution you're looking for.

    – Arjen Miedema
    Feb 27 '18 at 6:24














0












0








0







Finally , i have found the solution. May be it's not the best solution , but it works



I have just commented line number 422 with script



->setWeight($this->getProduct()->getWeight()) 


coming inside setProduct function in the below file



/vendor/magento/module-quote/Model/Quote/Item.php


And its working for me.






share|improve this answer













Finally , i have found the solution. May be it's not the best solution , but it works



I have just commented line number 422 with script



->setWeight($this->getProduct()->getWeight()) 


coming inside setProduct function in the below file



/vendor/magento/module-quote/Model/Quote/Item.php


And its working for me.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 28 '16 at 7:42









Dinesh SainiDinesh Saini

400217




400217













  • You know that changing code in a file that's in vendor will be overwritten as soon as a newer version of that file/module is available and installed. I have to be honest, I don't know the answer right away, but I don't think this will be the solution you're looking for.

    – Arjen Miedema
    Feb 27 '18 at 6:24



















  • You know that changing code in a file that's in vendor will be overwritten as soon as a newer version of that file/module is available and installed. I have to be honest, I don't know the answer right away, but I don't think this will be the solution you're looking for.

    – Arjen Miedema
    Feb 27 '18 at 6:24

















You know that changing code in a file that's in vendor will be overwritten as soon as a newer version of that file/module is available and installed. I have to be honest, I don't know the answer right away, but I don't think this will be the solution you're looking for.

– Arjen Miedema
Feb 27 '18 at 6:24





You know that changing code in a file that's in vendor will be overwritten as soon as a newer version of that file/module is available and installed. I have to be honest, I don't know the answer right away, but I don't think this will be the solution you're looking for.

– Arjen Miedema
Feb 27 '18 at 6:24


















draft saved

draft discarded




















































Thanks for contributing an answer to Magento Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f145662%2fmagento-2-checkout-cart-product-add-after-observer-setweight-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

“%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

夢乃愛華...