Magento 2.3: get cart items inside the cron file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I want to get current quote data for cronjob in cron/run.php
But my code it's not working.
Magento2 version is CE 2.2.6. Here is my code
<?php
namespace ABCAbandonCron;
use PsrLogLoggerInterface;
class Run
{
protected $logger;
protected $scopeConfig;
public function __construct(
LoggerInterface $logger,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
){
$this->logger = $logger;
$this->scopeConfig = $scopeConfig;
}
public function execute()
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cartObj = $objectManager->get('MagentoCheckoutModelCart');
$quoteId = $cartObj->getQuote()->getId();
$itemsArray = $cartObj->getQuote()->getAllItems();
foreach($itemsArray as $item)
{
$productName = $item->getName();
}
if(is_array($productName)){
$productNames .= implode(';',$productName);
}
$abdata['productNames'] = $productNames;
$abdata['quoteid'] = $quoteId;
return $abdata;
}
}
I am not able to get cart session data inside the cron run.php
file.
any suggestion? Thanks
magento2 cart session quote crontab
|
show 1 more comment
I want to get current quote data for cronjob in cron/run.php
But my code it's not working.
Magento2 version is CE 2.2.6. Here is my code
<?php
namespace ABCAbandonCron;
use PsrLogLoggerInterface;
class Run
{
protected $logger;
protected $scopeConfig;
public function __construct(
LoggerInterface $logger,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
){
$this->logger = $logger;
$this->scopeConfig = $scopeConfig;
}
public function execute()
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cartObj = $objectManager->get('MagentoCheckoutModelCart');
$quoteId = $cartObj->getQuote()->getId();
$itemsArray = $cartObj->getQuote()->getAllItems();
foreach($itemsArray as $item)
{
$productName = $item->getName();
}
if(is_array($productName)){
$productNames .= implode(';',$productName);
}
$abdata['productNames'] = $productNames;
$abdata['quoteid'] = $quoteId;
return $abdata;
}
}
I am not able to get cart session data inside the cron run.php
file.
any suggestion? Thanks
magento2 cart session quote crontab
I think code working fine. Please check your cron
– ARUNPRABAKARAN M
yesterday
@ARUNPRABAKARANM cron is working fine. Only the problem is with the cart session. I am not able to GET cart data in cron run.php file.
– Pankaj Sharma
yesterday
Kindly check my code
– ARUNPRABAKARAN M
yesterday
You can not get the current quote from cron, you will need to load quote by customer id.
– Ashish Viradiya
yesterday
@AshishViradiya do you have any reference for this?
– Pankaj Sharma
yesterday
|
show 1 more comment
I want to get current quote data for cronjob in cron/run.php
But my code it's not working.
Magento2 version is CE 2.2.6. Here is my code
<?php
namespace ABCAbandonCron;
use PsrLogLoggerInterface;
class Run
{
protected $logger;
protected $scopeConfig;
public function __construct(
LoggerInterface $logger,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
){
$this->logger = $logger;
$this->scopeConfig = $scopeConfig;
}
public function execute()
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cartObj = $objectManager->get('MagentoCheckoutModelCart');
$quoteId = $cartObj->getQuote()->getId();
$itemsArray = $cartObj->getQuote()->getAllItems();
foreach($itemsArray as $item)
{
$productName = $item->getName();
}
if(is_array($productName)){
$productNames .= implode(';',$productName);
}
$abdata['productNames'] = $productNames;
$abdata['quoteid'] = $quoteId;
return $abdata;
}
}
I am not able to get cart session data inside the cron run.php
file.
any suggestion? Thanks
magento2 cart session quote crontab
I want to get current quote data for cronjob in cron/run.php
But my code it's not working.
Magento2 version is CE 2.2.6. Here is my code
<?php
namespace ABCAbandonCron;
use PsrLogLoggerInterface;
class Run
{
protected $logger;
protected $scopeConfig;
public function __construct(
LoggerInterface $logger,
MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
){
$this->logger = $logger;
$this->scopeConfig = $scopeConfig;
}
public function execute()
{
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cartObj = $objectManager->get('MagentoCheckoutModelCart');
$quoteId = $cartObj->getQuote()->getId();
$itemsArray = $cartObj->getQuote()->getAllItems();
foreach($itemsArray as $item)
{
$productName = $item->getName();
}
if(is_array($productName)){
$productNames .= implode(';',$productName);
}
$abdata['productNames'] = $productNames;
$abdata['quoteid'] = $quoteId;
return $abdata;
}
}
I am not able to get cart session data inside the cron run.php
file.
any suggestion? Thanks
magento2 cart session quote crontab
magento2 cart session quote crontab
edited yesterday
ARUNPRABAKARAN M
409113
409113
asked yesterday
Pankaj SharmaPankaj Sharma
5781623
5781623
I think code working fine. Please check your cron
– ARUNPRABAKARAN M
yesterday
@ARUNPRABAKARANM cron is working fine. Only the problem is with the cart session. I am not able to GET cart data in cron run.php file.
– Pankaj Sharma
yesterday
Kindly check my code
– ARUNPRABAKARAN M
yesterday
You can not get the current quote from cron, you will need to load quote by customer id.
– Ashish Viradiya
yesterday
@AshishViradiya do you have any reference for this?
– Pankaj Sharma
yesterday
|
show 1 more comment
I think code working fine. Please check your cron
– ARUNPRABAKARAN M
yesterday
@ARUNPRABAKARANM cron is working fine. Only the problem is with the cart session. I am not able to GET cart data in cron run.php file.
– Pankaj Sharma
yesterday
Kindly check my code
– ARUNPRABAKARAN M
yesterday
You can not get the current quote from cron, you will need to load quote by customer id.
– Ashish Viradiya
yesterday
@AshishViradiya do you have any reference for this?
– Pankaj Sharma
yesterday
I think code working fine. Please check your cron
– ARUNPRABAKARAN M
yesterday
I think code working fine. Please check your cron
– ARUNPRABAKARAN M
yesterday
@ARUNPRABAKARANM cron is working fine. Only the problem is with the cart session. I am not able to GET cart data in cron run.php file.
– Pankaj Sharma
yesterday
@ARUNPRABAKARANM cron is working fine. Only the problem is with the cart session. I am not able to GET cart data in cron run.php file.
– Pankaj Sharma
yesterday
Kindly check my code
– ARUNPRABAKARAN M
yesterday
Kindly check my code
– ARUNPRABAKARAN M
yesterday
You can not get the current quote from cron, you will need to load quote by customer id.
– Ashish Viradiya
yesterday
You can not get the current quote from cron, you will need to load quote by customer id.
– Ashish Viradiya
yesterday
@AshishViradiya do you have any reference for this?
– Pankaj Sharma
yesterday
@AshishViradiya do you have any reference for this?
– Pankaj Sharma
yesterday
|
show 1 more comment
1 Answer
1
active
oldest
votes
Following code will be helpful
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cartObj = $objectManager->get('MagentoCheckoutModelCart');
$quoteId = $cartObj->getQuote()->getId();
$itemsArray = $cartObj->getQuote()->getAllItems();
foreach($itemsArray as $item)
{
$productName = $item->getName();
}
$abdata=;
if(isset($productName)){
$productNames = implode(';',$productName);
$abdata['productNames'] = $productNames;
$abdata['quoteid'] = $quoteId;
}
return $abdata;
}
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%2f269106%2fmagento-2-3-get-cart-items-inside-the-cron-file%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
Following code will be helpful
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cartObj = $objectManager->get('MagentoCheckoutModelCart');
$quoteId = $cartObj->getQuote()->getId();
$itemsArray = $cartObj->getQuote()->getAllItems();
foreach($itemsArray as $item)
{
$productName = $item->getName();
}
$abdata=;
if(isset($productName)){
$productNames = implode(';',$productName);
$abdata['productNames'] = $productNames;
$abdata['quoteid'] = $quoteId;
}
return $abdata;
}
add a comment |
Following code will be helpful
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cartObj = $objectManager->get('MagentoCheckoutModelCart');
$quoteId = $cartObj->getQuote()->getId();
$itemsArray = $cartObj->getQuote()->getAllItems();
foreach($itemsArray as $item)
{
$productName = $item->getName();
}
$abdata=;
if(isset($productName)){
$productNames = implode(';',$productName);
$abdata['productNames'] = $productNames;
$abdata['quoteid'] = $quoteId;
}
return $abdata;
}
add a comment |
Following code will be helpful
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cartObj = $objectManager->get('MagentoCheckoutModelCart');
$quoteId = $cartObj->getQuote()->getId();
$itemsArray = $cartObj->getQuote()->getAllItems();
foreach($itemsArray as $item)
{
$productName = $item->getName();
}
$abdata=;
if(isset($productName)){
$productNames = implode(';',$productName);
$abdata['productNames'] = $productNames;
$abdata['quoteid'] = $quoteId;
}
return $abdata;
}
Following code will be helpful
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$cartObj = $objectManager->get('MagentoCheckoutModelCart');
$quoteId = $cartObj->getQuote()->getId();
$itemsArray = $cartObj->getQuote()->getAllItems();
foreach($itemsArray as $item)
{
$productName = $item->getName();
}
$abdata=;
if(isset($productName)){
$productNames = implode(';',$productName);
$abdata['productNames'] = $productNames;
$abdata['quoteid'] = $quoteId;
}
return $abdata;
}
edited yesterday
answered yesterday
ARUNPRABAKARAN MARUNPRABAKARAN M
409113
409113
add a comment |
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%2f269106%2fmagento-2-3-get-cart-items-inside-the-cron-file%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
I think code working fine. Please check your cron
– ARUNPRABAKARAN M
yesterday
@ARUNPRABAKARANM cron is working fine. Only the problem is with the cart session. I am not able to GET cart data in cron run.php file.
– Pankaj Sharma
yesterday
Kindly check my code
– ARUNPRABAKARAN M
yesterday
You can not get the current quote from cron, you will need to load quote by customer id.
– Ashish Viradiya
yesterday
@AshishViradiya do you have any reference for this?
– Pankaj Sharma
yesterday