Magento 2 checkout_cart_product_add_after Observer setWeight not working Planned maintenance scheduled April 23, 2019 at 23:30UTC (7:30pm 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

Intuitive explanation of the rank-nullity theorem

Crossing US/Canada Border for less than 24 hours

Project Euler #1 in C++

How long can equipment go unused before powering up runs the risk of damage?

Why weren't discrete x86 CPUs ever used in game hardware?

preposition before coffee

A letter with no particular backstory

What does 丫 mean? 丫是什么意思?

Google .dev domain strangely redirects to https

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

Co-worker has annoying ringtone

What is the meaning of 'breadth' in breadth first search?

Can a Beast Master ranger change beast companions?

Did any compiler fully use 80-bit floating point?

Why are vacuum tubes still used in amateur radios?

Drawing spherical mirrors

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

Why can't I install Tomboy in Ubuntu Mate 19.04?

How to run automated tests after each commit?

What order were files/directories output in dir?

Is there hard evidence that the grant peer review system performs significantly better than random?

How can I prevent/balance waiting and turtling as a response to cooldown mechanics

What does this say in Elvish?

Why does 14 CFR have skipped subparts in my ASA 2019 FAR/AIM book?



Magento 2 checkout_cart_product_add_after Observer setWeight not working



Planned maintenance scheduled April 23, 2019 at 23:30UTC (7:30pm 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 2 days 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 2 days 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 2 days 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 2 days 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

Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림