How to get quote item id in checkout_cart_product_add_after observer in magento2Observer checkout_cart_product_add_after get product quantity in cartcheckout_cart_add_product_complete get quote itemget cart/quote in Observerquote item price information missing in checkout_cart_product_add_after eventObserver (checkout_cart_product_add_after) Not FiringModel class not found in …/magento/framework/ObjectManager/Factory/AbstractFactory.php:93Magento 2: Add a product to the cart programmaticallyHow to Update Magento 2 configurable child products price by REST APIget Quote Item ID from event checkout_cart_product_add_after not workingMagento2: How to get quote item through item id?
What does KSP mean?
Why is current rating for multicore cable lower than single core with the same cross section?
How to make a pipeline wait for end-of-file or stop after an error?
How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?
French for 'It must be my imagination'?
How would one muzzle a full grown polar bear in the 13th century?
Packing rectangles: Does rotation ever help?
Question relating to a number theoretic function
How to verbalise code in Mathematica?
Why do Computer Science majors learn Calculus?
Does this extra sentence in the description of the warlock's Eyes of the Rune Keeper eldritch invocation appear in any official reference?
Was it really necessary for the Lunar module LM to have 2 stages?
What is the difference between `a[bc]d` (brackets) and `ab,cd` (braces)?
Error message with tabularx
Is thermodynamics only applicable to systems in equilibrium?
Fizzy, soft, pop and still drinks
Please, smoke with good manners
Do I have an "anti-research" personality?
How do Bards prepare spells?
Was there a Viking Exchange as well as a Columbian one?
Can someone publish a story that happened to you?
function to receive a character input and return date format (with incorrect input)
How could Tony Stark make this in Endgame?
Sci-fi book: portals appear in London and send a failed artist towards a designated path where he operate a giant superweapon
How to get quote item id in checkout_cart_product_add_after observer in magento2
Observer checkout_cart_product_add_after get product quantity in cartcheckout_cart_add_product_complete get quote itemget cart/quote in Observerquote item price information missing in checkout_cart_product_add_after eventObserver (checkout_cart_product_add_after) Not FiringModel class not found in …/magento/framework/ObjectManager/Factory/AbstractFactory.php:93Magento 2: Add a product to the cart programmaticallyHow to Update Magento 2 configurable child products price by REST APIget Quote Item ID from event checkout_cart_product_add_after not workingMagento2: How to get quote item through item id?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have setting the custom price of the product on adding to cart which I am doing through some observer .
Everything is working fine except I am not getting the item id in the observer.I tried different ways but not able to get the item id of the added product .
Below is the code for reference. If anybody has some idea please revert.
class CustomPrice implements ObserverInterface
protected $_request;
protected $_helper;
protected $cart;
public function __construct(MagentoFrameworkAppRequestInterface $request,TWProductHelperData $helper,MagentoCheckoutModelCart $cart)
$this->_request = $request;
$this->_helper = $helper;
$this->cart= $cart;
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP.'/var/log/my.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$reqeustParams = $this->_request->getParams();
$custom_price = $reqeustParams['custom_price'];
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item_id = $item->getId(); **// I get nothing in this**
$item->setCustomPrice($custom_price);
$item->setOriginalCustomPrice($custom_price);
$item->getProduct()->setIsSuperMode(true);
$pid = $item->getProductId();
$logger->info("item id=====pid ".$item_id." ==== ".$pid);
$this->_helper->updateIteminSession($pid,$item_id);
//$logger->info("success !!!!");
The response which i get on debug is below .. I don't see item id there :
[store_id] => 1
[product (MagentoCatalogModelProductInterceptor)] => Array
(
[store_id] => 1
[row_id] => 1
[entity_id] => 1
[created_in] => 1
[updated_in] => 2147483647
[attribute_set_id] => 4
[type_id] => simple
[sku] => 1
[has_options] => 0
[required_options] => 0
[created_at] => 2017-06-12 08:00:07
[updated_at] => 2017-06-12 08:00:07
[name] => Retro Eyeglasses
[meta_title] => Retro Eyeglasses
[meta_description] => Retro Eyeglasses
[image] => /1/1/118179.jpg
[small_image] => /1/1/118179.jpg
[thumbnail] => /1/1/118179.jpg
[options_container] => container2
[country_of_manufacture] => US
[url_key] => retro-eyeglasses
[gift_message_available] => 2
[gift_wrapping_available] => 2
[is_returnable] => 2
[swatch_image] => /1/1/118179.jpg
[meta_keyword] => Retro Eyeglasses
[price] => 12.9500
[weight] => 1.0000
[status] => 1
[visibility] => 4
[quantity_and_stock_status] => Array
(
[is_in_stock] => 1
[qty] => 999997
)
[tax_class_id] => 2
[options] => Array
(
)
[media_gallery] => Array
(
[images] => Array
(
[1] => Array
(
[value_id] => 1
[file] => /1/1/118179.jpg
[media_type] => image
[row_id] => 1
[position] => 1
[disabled] => 0
[position_default] => 1
[disabled_default] => 0
)
)
[values] => Array
(
)
)
[category_ids] => Array
(
[0] => 3
)
[tier_price] => Array
(
)
[tier_price_changed] => 0
[is_salable] => 1
[website_ids] => Array
(
[0] => 1
)
[cart_qty] => 1
[qty] => 1
[event] =>
)
[product_id] => 1
[product_type] => simple
[sku] => 1
[name] => Retro Eyeglasses
[weight] => 1.0000
[tax_class_id] => 2
[is_qty_decimal] =>
[qty_to_add] => 1
[qty] => 1
[qty_options] => Array
(
)
magento2 event-observer magento2-enterprise
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have setting the custom price of the product on adding to cart which I am doing through some observer .
Everything is working fine except I am not getting the item id in the observer.I tried different ways but not able to get the item id of the added product .
Below is the code for reference. If anybody has some idea please revert.
class CustomPrice implements ObserverInterface
protected $_request;
protected $_helper;
protected $cart;
public function __construct(MagentoFrameworkAppRequestInterface $request,TWProductHelperData $helper,MagentoCheckoutModelCart $cart)
$this->_request = $request;
$this->_helper = $helper;
$this->cart= $cart;
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP.'/var/log/my.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$reqeustParams = $this->_request->getParams();
$custom_price = $reqeustParams['custom_price'];
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item_id = $item->getId(); **// I get nothing in this**
$item->setCustomPrice($custom_price);
$item->setOriginalCustomPrice($custom_price);
$item->getProduct()->setIsSuperMode(true);
$pid = $item->getProductId();
$logger->info("item id=====pid ".$item_id." ==== ".$pid);
$this->_helper->updateIteminSession($pid,$item_id);
//$logger->info("success !!!!");
The response which i get on debug is below .. I don't see item id there :
[store_id] => 1
[product (MagentoCatalogModelProductInterceptor)] => Array
(
[store_id] => 1
[row_id] => 1
[entity_id] => 1
[created_in] => 1
[updated_in] => 2147483647
[attribute_set_id] => 4
[type_id] => simple
[sku] => 1
[has_options] => 0
[required_options] => 0
[created_at] => 2017-06-12 08:00:07
[updated_at] => 2017-06-12 08:00:07
[name] => Retro Eyeglasses
[meta_title] => Retro Eyeglasses
[meta_description] => Retro Eyeglasses
[image] => /1/1/118179.jpg
[small_image] => /1/1/118179.jpg
[thumbnail] => /1/1/118179.jpg
[options_container] => container2
[country_of_manufacture] => US
[url_key] => retro-eyeglasses
[gift_message_available] => 2
[gift_wrapping_available] => 2
[is_returnable] => 2
[swatch_image] => /1/1/118179.jpg
[meta_keyword] => Retro Eyeglasses
[price] => 12.9500
[weight] => 1.0000
[status] => 1
[visibility] => 4
[quantity_and_stock_status] => Array
(
[is_in_stock] => 1
[qty] => 999997
)
[tax_class_id] => 2
[options] => Array
(
)
[media_gallery] => Array
(
[images] => Array
(
[1] => Array
(
[value_id] => 1
[file] => /1/1/118179.jpg
[media_type] => image
[row_id] => 1
[position] => 1
[disabled] => 0
[position_default] => 1
[disabled_default] => 0
)
)
[values] => Array
(
)
)
[category_ids] => Array
(
[0] => 3
)
[tier_price] => Array
(
)
[tier_price_changed] => 0
[is_salable] => 1
[website_ids] => Array
(
[0] => 1
)
[cart_qty] => 1
[qty] => 1
[event] =>
)
[product_id] => 1
[product_type] => simple
[sku] => 1
[name] => Retro Eyeglasses
[weight] => 1.0000
[tax_class_id] => 2
[is_qty_decimal] =>
[qty_to_add] => 1
[qty] => 1
[qty_options] => Array
(
)
magento2 event-observer magento2-enterprise
bumped to the homepage by Community♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have setting the custom price of the product on adding to cart which I am doing through some observer .
Everything is working fine except I am not getting the item id in the observer.I tried different ways but not able to get the item id of the added product .
Below is the code for reference. If anybody has some idea please revert.
class CustomPrice implements ObserverInterface
protected $_request;
protected $_helper;
protected $cart;
public function __construct(MagentoFrameworkAppRequestInterface $request,TWProductHelperData $helper,MagentoCheckoutModelCart $cart)
$this->_request = $request;
$this->_helper = $helper;
$this->cart= $cart;
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP.'/var/log/my.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$reqeustParams = $this->_request->getParams();
$custom_price = $reqeustParams['custom_price'];
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item_id = $item->getId(); **// I get nothing in this**
$item->setCustomPrice($custom_price);
$item->setOriginalCustomPrice($custom_price);
$item->getProduct()->setIsSuperMode(true);
$pid = $item->getProductId();
$logger->info("item id=====pid ".$item_id." ==== ".$pid);
$this->_helper->updateIteminSession($pid,$item_id);
//$logger->info("success !!!!");
The response which i get on debug is below .. I don't see item id there :
[store_id] => 1
[product (MagentoCatalogModelProductInterceptor)] => Array
(
[store_id] => 1
[row_id] => 1
[entity_id] => 1
[created_in] => 1
[updated_in] => 2147483647
[attribute_set_id] => 4
[type_id] => simple
[sku] => 1
[has_options] => 0
[required_options] => 0
[created_at] => 2017-06-12 08:00:07
[updated_at] => 2017-06-12 08:00:07
[name] => Retro Eyeglasses
[meta_title] => Retro Eyeglasses
[meta_description] => Retro Eyeglasses
[image] => /1/1/118179.jpg
[small_image] => /1/1/118179.jpg
[thumbnail] => /1/1/118179.jpg
[options_container] => container2
[country_of_manufacture] => US
[url_key] => retro-eyeglasses
[gift_message_available] => 2
[gift_wrapping_available] => 2
[is_returnable] => 2
[swatch_image] => /1/1/118179.jpg
[meta_keyword] => Retro Eyeglasses
[price] => 12.9500
[weight] => 1.0000
[status] => 1
[visibility] => 4
[quantity_and_stock_status] => Array
(
[is_in_stock] => 1
[qty] => 999997
)
[tax_class_id] => 2
[options] => Array
(
)
[media_gallery] => Array
(
[images] => Array
(
[1] => Array
(
[value_id] => 1
[file] => /1/1/118179.jpg
[media_type] => image
[row_id] => 1
[position] => 1
[disabled] => 0
[position_default] => 1
[disabled_default] => 0
)
)
[values] => Array
(
)
)
[category_ids] => Array
(
[0] => 3
)
[tier_price] => Array
(
)
[tier_price_changed] => 0
[is_salable] => 1
[website_ids] => Array
(
[0] => 1
)
[cart_qty] => 1
[qty] => 1
[event] =>
)
[product_id] => 1
[product_type] => simple
[sku] => 1
[name] => Retro Eyeglasses
[weight] => 1.0000
[tax_class_id] => 2
[is_qty_decimal] =>
[qty_to_add] => 1
[qty] => 1
[qty_options] => Array
(
)
magento2 event-observer magento2-enterprise
I have setting the custom price of the product on adding to cart which I am doing through some observer .
Everything is working fine except I am not getting the item id in the observer.I tried different ways but not able to get the item id of the added product .
Below is the code for reference. If anybody has some idea please revert.
class CustomPrice implements ObserverInterface
protected $_request;
protected $_helper;
protected $cart;
public function __construct(MagentoFrameworkAppRequestInterface $request,TWProductHelperData $helper,MagentoCheckoutModelCart $cart)
$this->_request = $request;
$this->_helper = $helper;
$this->cart= $cart;
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP.'/var/log/my.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$reqeustParams = $this->_request->getParams();
$custom_price = $reqeustParams['custom_price'];
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item_id = $item->getId(); **// I get nothing in this**
$item->setCustomPrice($custom_price);
$item->setOriginalCustomPrice($custom_price);
$item->getProduct()->setIsSuperMode(true);
$pid = $item->getProductId();
$logger->info("item id=====pid ".$item_id." ==== ".$pid);
$this->_helper->updateIteminSession($pid,$item_id);
//$logger->info("success !!!!");
The response which i get on debug is below .. I don't see item id there :
[store_id] => 1
[product (MagentoCatalogModelProductInterceptor)] => Array
(
[store_id] => 1
[row_id] => 1
[entity_id] => 1
[created_in] => 1
[updated_in] => 2147483647
[attribute_set_id] => 4
[type_id] => simple
[sku] => 1
[has_options] => 0
[required_options] => 0
[created_at] => 2017-06-12 08:00:07
[updated_at] => 2017-06-12 08:00:07
[name] => Retro Eyeglasses
[meta_title] => Retro Eyeglasses
[meta_description] => Retro Eyeglasses
[image] => /1/1/118179.jpg
[small_image] => /1/1/118179.jpg
[thumbnail] => /1/1/118179.jpg
[options_container] => container2
[country_of_manufacture] => US
[url_key] => retro-eyeglasses
[gift_message_available] => 2
[gift_wrapping_available] => 2
[is_returnable] => 2
[swatch_image] => /1/1/118179.jpg
[meta_keyword] => Retro Eyeglasses
[price] => 12.9500
[weight] => 1.0000
[status] => 1
[visibility] => 4
[quantity_and_stock_status] => Array
(
[is_in_stock] => 1
[qty] => 999997
)
[tax_class_id] => 2
[options] => Array
(
)
[media_gallery] => Array
(
[images] => Array
(
[1] => Array
(
[value_id] => 1
[file] => /1/1/118179.jpg
[media_type] => image
[row_id] => 1
[position] => 1
[disabled] => 0
[position_default] => 1
[disabled_default] => 0
)
)
[values] => Array
(
)
)
[category_ids] => Array
(
[0] => 3
)
[tier_price] => Array
(
)
[tier_price_changed] => 0
[is_salable] => 1
[website_ids] => Array
(
[0] => 1
)
[cart_qty] => 1
[qty] => 1
[event] =>
)
[product_id] => 1
[product_type] => simple
[sku] => 1
[name] => Retro Eyeglasses
[weight] => 1.0000
[tax_class_id] => 2
[is_qty_decimal] =>
[qty_to_add] => 1
[qty] => 1
[qty_options] => Array
(
)
magento2 event-observer magento2-enterprise
magento2 event-observer magento2-enterprise
edited Sep 18 '17 at 13:54
ssnegi
asked Sep 18 '17 at 8:49
ssnegissnegi
227
227
bumped to the homepage by Community♦ 11 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♦ 11 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You need to do like
$id = $item->getItemId()
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP.'/var/log/my.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$reqeustParams = $this->_request->getParams();
$custom_price = $reqeustParams['custom_price'];
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item_id = $item->getItemId(); **// I get nothing in this**
$item->setCustomPrice($custom_price);
$item->setOriginalCustomPrice($custom_price);
$item->getProduct()->setIsSuperMode(true);
$pid = $item->getProductId();
$logger->info("item id=====pid ".$item_id." ==== ".$pid);
$this->_helper->updateIteminSession($pid,$item_id);
//$logger->info("success !!!!");
Thanks Rakesh .. but after trying that also I am not getting the item id .. I did the same in the Magento1.x and it worked .. but not sure why not happening in M2.
– ssnegi
Sep 18 '17 at 13:34
just try with echo "<pre>";print_r($item->debug()); and check id is found or not?
– Rakesh Jesadiya
Sep 18 '17 at 13:44
Please check the result above on debug..I don't see item id there .
– ssnegi
Sep 18 '17 at 13:55
I noticed that when I add a product first time it did not show item id .. but when i add same product again ..it shows the item id
– ssnegi
Sep 19 '17 at 1:23
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f193578%2fhow-to-get-quote-item-id-in-checkout-cart-product-add-after-observer-in-magento2%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
You need to do like
$id = $item->getItemId()
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP.'/var/log/my.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$reqeustParams = $this->_request->getParams();
$custom_price = $reqeustParams['custom_price'];
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item_id = $item->getItemId(); **// I get nothing in this**
$item->setCustomPrice($custom_price);
$item->setOriginalCustomPrice($custom_price);
$item->getProduct()->setIsSuperMode(true);
$pid = $item->getProductId();
$logger->info("item id=====pid ".$item_id." ==== ".$pid);
$this->_helper->updateIteminSession($pid,$item_id);
//$logger->info("success !!!!");
Thanks Rakesh .. but after trying that also I am not getting the item id .. I did the same in the Magento1.x and it worked .. but not sure why not happening in M2.
– ssnegi
Sep 18 '17 at 13:34
just try with echo "<pre>";print_r($item->debug()); and check id is found or not?
– Rakesh Jesadiya
Sep 18 '17 at 13:44
Please check the result above on debug..I don't see item id there .
– ssnegi
Sep 18 '17 at 13:55
I noticed that when I add a product first time it did not show item id .. but when i add same product again ..it shows the item id
– ssnegi
Sep 19 '17 at 1:23
add a comment |
You need to do like
$id = $item->getItemId()
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP.'/var/log/my.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$reqeustParams = $this->_request->getParams();
$custom_price = $reqeustParams['custom_price'];
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item_id = $item->getItemId(); **// I get nothing in this**
$item->setCustomPrice($custom_price);
$item->setOriginalCustomPrice($custom_price);
$item->getProduct()->setIsSuperMode(true);
$pid = $item->getProductId();
$logger->info("item id=====pid ".$item_id." ==== ".$pid);
$this->_helper->updateIteminSession($pid,$item_id);
//$logger->info("success !!!!");
Thanks Rakesh .. but after trying that also I am not getting the item id .. I did the same in the Magento1.x and it worked .. but not sure why not happening in M2.
– ssnegi
Sep 18 '17 at 13:34
just try with echo "<pre>";print_r($item->debug()); and check id is found or not?
– Rakesh Jesadiya
Sep 18 '17 at 13:44
Please check the result above on debug..I don't see item id there .
– ssnegi
Sep 18 '17 at 13:55
I noticed that when I add a product first time it did not show item id .. but when i add same product again ..it shows the item id
– ssnegi
Sep 19 '17 at 1:23
add a comment |
You need to do like
$id = $item->getItemId()
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP.'/var/log/my.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$reqeustParams = $this->_request->getParams();
$custom_price = $reqeustParams['custom_price'];
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item_id = $item->getItemId(); **// I get nothing in this**
$item->setCustomPrice($custom_price);
$item->setOriginalCustomPrice($custom_price);
$item->getProduct()->setIsSuperMode(true);
$pid = $item->getProductId();
$logger->info("item id=====pid ".$item_id." ==== ".$pid);
$this->_helper->updateIteminSession($pid,$item_id);
//$logger->info("success !!!!");
You need to do like
$id = $item->getItemId()
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP.'/var/log/my.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$reqeustParams = $this->_request->getParams();
$custom_price = $reqeustParams['custom_price'];
$item = $observer->getEvent()->getData('quote_item');
$item = ( $item->getParentItem() ? $item->getParentItem() : $item );
$item_id = $item->getItemId(); **// I get nothing in this**
$item->setCustomPrice($custom_price);
$item->setOriginalCustomPrice($custom_price);
$item->getProduct()->setIsSuperMode(true);
$pid = $item->getProductId();
$logger->info("item id=====pid ".$item_id." ==== ".$pid);
$this->_helper->updateIteminSession($pid,$item_id);
//$logger->info("success !!!!");
answered Sep 18 '17 at 9:01
Rakesh JesadiyaRakesh Jesadiya
30.5k1577126
30.5k1577126
Thanks Rakesh .. but after trying that also I am not getting the item id .. I did the same in the Magento1.x and it worked .. but not sure why not happening in M2.
– ssnegi
Sep 18 '17 at 13:34
just try with echo "<pre>";print_r($item->debug()); and check id is found or not?
– Rakesh Jesadiya
Sep 18 '17 at 13:44
Please check the result above on debug..I don't see item id there .
– ssnegi
Sep 18 '17 at 13:55
I noticed that when I add a product first time it did not show item id .. but when i add same product again ..it shows the item id
– ssnegi
Sep 19 '17 at 1:23
add a comment |
Thanks Rakesh .. but after trying that also I am not getting the item id .. I did the same in the Magento1.x and it worked .. but not sure why not happening in M2.
– ssnegi
Sep 18 '17 at 13:34
just try with echo "<pre>";print_r($item->debug()); and check id is found or not?
– Rakesh Jesadiya
Sep 18 '17 at 13:44
Please check the result above on debug..I don't see item id there .
– ssnegi
Sep 18 '17 at 13:55
I noticed that when I add a product first time it did not show item id .. but when i add same product again ..it shows the item id
– ssnegi
Sep 19 '17 at 1:23
Thanks Rakesh .. but after trying that also I am not getting the item id .. I did the same in the Magento1.x and it worked .. but not sure why not happening in M2.
– ssnegi
Sep 18 '17 at 13:34
Thanks Rakesh .. but after trying that also I am not getting the item id .. I did the same in the Magento1.x and it worked .. but not sure why not happening in M2.
– ssnegi
Sep 18 '17 at 13:34
just try with echo "<pre>";print_r($item->debug()); and check id is found or not?
– Rakesh Jesadiya
Sep 18 '17 at 13:44
just try with echo "<pre>";print_r($item->debug()); and check id is found or not?
– Rakesh Jesadiya
Sep 18 '17 at 13:44
Please check the result above on debug..I don't see item id there .
– ssnegi
Sep 18 '17 at 13:55
Please check the result above on debug..I don't see item id there .
– ssnegi
Sep 18 '17 at 13:55
I noticed that when I add a product first time it did not show item id .. but when i add same product again ..it shows the item id
– ssnegi
Sep 19 '17 at 1:23
I noticed that when I add a product first time it did not show item id .. but when i add same product again ..it shows the item id
– ssnegi
Sep 19 '17 at 1:23
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f193578%2fhow-to-get-quote-item-id-in-checkout-cart-product-add-after-observer-in-magento2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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