Does not work events magento 2main.CRITICAL: Plugin class doesn't existSet custom price of product when adding to cart code not workingMagento 2 Log Bundle Product Data in List Page?Magento 2: Add a product to the cart programmaticallyMagento 2 Create dynamic array From different Model Collection to use in multi select in gridMonolog Error After 2.2 UpgradeMagento 2: After custom cookie is created all pages default to home pageI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?
Why is my log file so massive? 22gb. I am running log backups
What do the Banks children have against barley water?
How can I fix this gap between bookcases I made?
Can a planet have a different gravitational pull depending on its location in orbit around its sun?
Unbreakable Formation vs. Cry of the Carnarium
Why do UK politicians seemingly ignore opinion polls on Brexit?
"My colleague's body is amazing"
Manga about a female worker who got dragged into another world together with this high school girl and she was just told she's not needed anymore
OA final episode explanation
Does a dangling wire really electrocute me if I'm standing in water?
Why is making salt water prohibited on Shabbat?
Doomsday-clock for my fantasy planet
Can I legally use front facing blue light in the UK?
Why was the "bread communication" in the arena of Catching Fire left out in the movie?
Does it makes sense to buy a new cycle to learn riding?
Extreme, but not acceptable situation and I can't start the work tomorrow morning
Calculate Levenshtein distance between two strings in Python
aging parents with no investments
Can produce flame be used to grapple, or as an unarmed strike, in the right circumstances?
Is Social Media Science Fiction?
Some basic questions on halt and move in Turing machines
Is domain driven design an anti-SQL pattern?
Ideas for colorfully and clearly highlighting graph edges according to weights
Why airport relocation isn't done gradually?
Does not work events magento 2
main.CRITICAL: Plugin class doesn't existSet custom price of product when adding to cart code not workingMagento 2 Log Bundle Product Data in List Page?Magento 2: Add a product to the cart programmaticallyMagento 2 Create dynamic array From different Model Collection to use in multi select in gridMonolog Error After 2.2 UpgradeMagento 2: After custom cookie is created all pages default to home pageI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Events do not work when I go to the product page.
events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="adding_to_cart_before">
<observer name="attributesProduct" instance="RonisSameDayDeliveryObserverDayDelivery" />
</event>
</config>
DayDelivery.php
<?php
namespace RonisSameDayDeliveryObserver;
use MagentoFrameworkEventObserverInterface;
class DayDelivery implements ObserverInterface
protected $resultPageFactory;
/**
* @var MagentoCheckoutModelCart
*/
protected $_cart;
/**
* [__construct description]
* @param MagentoFrameworkAppActionContext $context [description]
* @param MagentoFrameworkViewResultPageFactory $resultPageFactory [description]
* @param MagentoCheckoutModelCart $cart [description]
*/
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory,
MagentoCheckoutModelCart $cart
)
$this->resultPageFactory = $resultPageFactory;
$this->_cart = $cart;
parent::__construct($context);
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP . '/var/log/daydelivery.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$productInfo = $this->_cart->getQuote()->getItemsCollection();
$logger->info('-------------------------');
foreach ($productInfo as $item)
$item->getProductId();
$logger->info($item->getProductId());
if($item->getProductId() == '1')
echo "Item available in cart";
else
echo "Item not available in cart";
magento2 event-observer
|
show 2 more comments
Events do not work when I go to the product page.
events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="adding_to_cart_before">
<observer name="attributesProduct" instance="RonisSameDayDeliveryObserverDayDelivery" />
</event>
</config>
DayDelivery.php
<?php
namespace RonisSameDayDeliveryObserver;
use MagentoFrameworkEventObserverInterface;
class DayDelivery implements ObserverInterface
protected $resultPageFactory;
/**
* @var MagentoCheckoutModelCart
*/
protected $_cart;
/**
* [__construct description]
* @param MagentoFrameworkAppActionContext $context [description]
* @param MagentoFrameworkViewResultPageFactory $resultPageFactory [description]
* @param MagentoCheckoutModelCart $cart [description]
*/
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory,
MagentoCheckoutModelCart $cart
)
$this->resultPageFactory = $resultPageFactory;
$this->_cart = $cart;
parent::__construct($context);
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP . '/var/log/daydelivery.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$productInfo = $this->_cart->getQuote()->getItemsCollection();
$logger->info('-------------------------');
foreach ($productInfo as $item)
$item->getProductId();
$logger->info($item->getProductId());
if($item->getProductId() == '1')
echo "Item available in cart";
else
echo "Item not available in cart";
magento2 event-observer
Have you got any error? or any log in the log file?
– Chirag Patel
10 hours ago
No, and does not write anything to my log
– Рома Лытарь
10 hours ago
What's that event?? when you want that event to be triggered?
– Prathap Gunasekaran
10 hours ago
When I go to the product page
– Рома Лытарь
10 hours ago
You mean each time when you go for product page
– Prathap Gunasekaran
10 hours ago
|
show 2 more comments
Events do not work when I go to the product page.
events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="adding_to_cart_before">
<observer name="attributesProduct" instance="RonisSameDayDeliveryObserverDayDelivery" />
</event>
</config>
DayDelivery.php
<?php
namespace RonisSameDayDeliveryObserver;
use MagentoFrameworkEventObserverInterface;
class DayDelivery implements ObserverInterface
protected $resultPageFactory;
/**
* @var MagentoCheckoutModelCart
*/
protected $_cart;
/**
* [__construct description]
* @param MagentoFrameworkAppActionContext $context [description]
* @param MagentoFrameworkViewResultPageFactory $resultPageFactory [description]
* @param MagentoCheckoutModelCart $cart [description]
*/
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory,
MagentoCheckoutModelCart $cart
)
$this->resultPageFactory = $resultPageFactory;
$this->_cart = $cart;
parent::__construct($context);
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP . '/var/log/daydelivery.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$productInfo = $this->_cart->getQuote()->getItemsCollection();
$logger->info('-------------------------');
foreach ($productInfo as $item)
$item->getProductId();
$logger->info($item->getProductId());
if($item->getProductId() == '1')
echo "Item available in cart";
else
echo "Item not available in cart";
magento2 event-observer
Events do not work when I go to the product page.
events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="adding_to_cart_before">
<observer name="attributesProduct" instance="RonisSameDayDeliveryObserverDayDelivery" />
</event>
</config>
DayDelivery.php
<?php
namespace RonisSameDayDeliveryObserver;
use MagentoFrameworkEventObserverInterface;
class DayDelivery implements ObserverInterface
protected $resultPageFactory;
/**
* @var MagentoCheckoutModelCart
*/
protected $_cart;
/**
* [__construct description]
* @param MagentoFrameworkAppActionContext $context [description]
* @param MagentoFrameworkViewResultPageFactory $resultPageFactory [description]
* @param MagentoCheckoutModelCart $cart [description]
*/
public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory,
MagentoCheckoutModelCart $cart
)
$this->resultPageFactory = $resultPageFactory;
$this->_cart = $cart;
parent::__construct($context);
public function execute(MagentoFrameworkEventObserver $observer)
$writer = new ZendLogWriterStream(BP . '/var/log/daydelivery.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
$productInfo = $this->_cart->getQuote()->getItemsCollection();
$logger->info('-------------------------');
foreach ($productInfo as $item)
$item->getProductId();
$logger->info($item->getProductId());
if($item->getProductId() == '1')
echo "Item available in cart";
else
echo "Item not available in cart";
magento2 event-observer
magento2 event-observer
asked 10 hours ago
Рома ЛытарьРома Лытарь
1719
1719
Have you got any error? or any log in the log file?
– Chirag Patel
10 hours ago
No, and does not write anything to my log
– Рома Лытарь
10 hours ago
What's that event?? when you want that event to be triggered?
– Prathap Gunasekaran
10 hours ago
When I go to the product page
– Рома Лытарь
10 hours ago
You mean each time when you go for product page
– Prathap Gunasekaran
10 hours ago
|
show 2 more comments
Have you got any error? or any log in the log file?
– Chirag Patel
10 hours ago
No, and does not write anything to my log
– Рома Лытарь
10 hours ago
What's that event?? when you want that event to be triggered?
– Prathap Gunasekaran
10 hours ago
When I go to the product page
– Рома Лытарь
10 hours ago
You mean each time when you go for product page
– Prathap Gunasekaran
10 hours ago
Have you got any error? or any log in the log file?
– Chirag Patel
10 hours ago
Have you got any error? or any log in the log file?
– Chirag Patel
10 hours ago
No, and does not write anything to my log
– Рома Лытарь
10 hours ago
No, and does not write anything to my log
– Рома Лытарь
10 hours ago
What's that event?? when you want that event to be triggered?
– Prathap Gunasekaran
10 hours ago
What's that event?? when you want that event to be triggered?
– Prathap Gunasekaran
10 hours ago
When I go to the product page
– Рома Лытарь
10 hours ago
When I go to the product page
– Рома Лытарь
10 hours ago
You mean each time when you go for product page
– Prathap Gunasekaran
10 hours ago
You mean each time when you go for product page
– Prathap Gunasekaran
10 hours ago
|
show 2 more comments
1 Answer
1
active
oldest
votes
Try this,
You should use this event controller_action_predispatch_catalog_product_view instead of adding_to_cart_before
but the problem is, it will trigger only on first time when you visit the product page, since it is cacheable page. You may try disable cacheable="false" to any of the block from product page and check then it will trigger all the time you visit.
NOTE : It's not recommended to disable cache on product page, so try using plugin to do that.
Hope this information helps.
and how can I now transfer these id's to the js template so that, depending on this ids, I showed a popup on the product page
– Рома Лытарь
9 hours ago
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%2f269186%2fdoes-not-work-events-magento-2%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
Try this,
You should use this event controller_action_predispatch_catalog_product_view instead of adding_to_cart_before
but the problem is, it will trigger only on first time when you visit the product page, since it is cacheable page. You may try disable cacheable="false" to any of the block from product page and check then it will trigger all the time you visit.
NOTE : It's not recommended to disable cache on product page, so try using plugin to do that.
Hope this information helps.
and how can I now transfer these id's to the js template so that, depending on this ids, I showed a popup on the product page
– Рома Лытарь
9 hours ago
add a comment |
Try this,
You should use this event controller_action_predispatch_catalog_product_view instead of adding_to_cart_before
but the problem is, it will trigger only on first time when you visit the product page, since it is cacheable page. You may try disable cacheable="false" to any of the block from product page and check then it will trigger all the time you visit.
NOTE : It's not recommended to disable cache on product page, so try using plugin to do that.
Hope this information helps.
and how can I now transfer these id's to the js template so that, depending on this ids, I showed a popup on the product page
– Рома Лытарь
9 hours ago
add a comment |
Try this,
You should use this event controller_action_predispatch_catalog_product_view instead of adding_to_cart_before
but the problem is, it will trigger only on first time when you visit the product page, since it is cacheable page. You may try disable cacheable="false" to any of the block from product page and check then it will trigger all the time you visit.
NOTE : It's not recommended to disable cache on product page, so try using plugin to do that.
Hope this information helps.
Try this,
You should use this event controller_action_predispatch_catalog_product_view instead of adding_to_cart_before
but the problem is, it will trigger only on first time when you visit the product page, since it is cacheable page. You may try disable cacheable="false" to any of the block from product page and check then it will trigger all the time you visit.
NOTE : It's not recommended to disable cache on product page, so try using plugin to do that.
Hope this information helps.
answered 9 hours ago
Prathap GunasekaranPrathap Gunasekaran
1,7611618
1,7611618
and how can I now transfer these id's to the js template so that, depending on this ids, I showed a popup on the product page
– Рома Лытарь
9 hours ago
add a comment |
and how can I now transfer these id's to the js template so that, depending on this ids, I showed a popup on the product page
– Рома Лытарь
9 hours ago
and how can I now transfer these id's to the js template so that, depending on this ids, I showed a popup on the product page
– Рома Лытарь
9 hours ago
and how can I now transfer these id's to the js template so that, depending on this ids, I showed a popup on the product page
– Рома Лытарь
9 hours ago
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%2f269186%2fdoes-not-work-events-magento-2%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
Have you got any error? or any log in the log file?
– Chirag Patel
10 hours ago
No, and does not write anything to my log
– Рома Лытарь
10 hours ago
What's that event?? when you want that event to be triggered?
– Prathap Gunasekaran
10 hours ago
When I go to the product page
– Рома Лытарь
10 hours ago
You mean each time when you go for product page
– Prathap Gunasekaran
10 hours ago