Access OrderRepositoryInterface interface from cron job The Next CEO of Stack OverflowUnit Test for overwrite collection class in magento2ScopeConfigInterface as parameter in constructor - Magento 2Get product collection filter by from and to date in magento2.I created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Magento Module creation gives errorI have created an extension to show Customer Company Name in Order grid. But when creating new order, order is not showing in order gridUncaught RuntimeException: Can't create directoryMagento 2 How to remove price filter from category if module is enable?Magento2 REST API get all customers detailsget invoice item using order_item_id in magento 2
It is correct to match light sources with the same color temperature?
What would be the main consequences for a country leaving the WTO?
How to find image of a complex function with given constraints?
Touchpad not working on Debian 9
How to get the last not-null value in an ordered column of a huge table?
Is it ok to trim down a tube patch?
Can someone explain this formula for calculating Manhattan distance?
Is a distribution that is normal, but highly skewed, considered Gaussian?
Expectation in a stochastic differential equation
Physiological effects of huge anime eyes
Is it professional to write unrelated content in an almost-empty email?
Audio Conversion With ADS1243
Strange use of "whether ... than ..." in official text
Help! I cannot understand this game’s notations!
Traduction de « Life is a roller coaster »
How did Beeri the Hittite come up with naming his daughter Yehudit?
Easy to read palindrome checker
Purpose of level-shifter with same in and out voltages
Is there a difference between "Fahrstuhl" and "Aufzug"?
Is it convenient to ask the journal's editor for two additional days to complete a review?
Decide between Polyglossia and Babel for LuaLaTeX in 2019
Calculate the Mean mean of two numbers
Expressing the idea of having a very busy time
What can the phrase “is embedded in a whale of a bill” mean?
Access OrderRepositoryInterface interface from cron job
The Next CEO of Stack OverflowUnit Test for overwrite collection class in magento2ScopeConfigInterface as parameter in constructor - Magento 2Get product collection filter by from and to date in magento2.I created a custom module ,but getting error, not able to figure out what the error is about. How to get out of this error?Magento Module creation gives errorI have created an extension to show Customer Company Name in Order grid. But when creating new order, order is not showing in order gridUncaught RuntimeException: Can't create directoryMagento 2 How to remove price filter from category if module is enable?Magento2 REST API get all customers detailsget invoice item using order_item_id in magento 2
I need to call API after user place order.
My issue is when my event method called after placing order it initializes variables as shown in the constructor.
public function __construct(
OrderRepositoryInterface $OrderRepositoryInterface , ScopeConfigInterface
$scopeConfig
)
$this->orderRepository = $OrderRepositoryInterface;
$this->scopeConfig = $scopeConfig;
$this->_resources = MagentoFrameworkAppObjectManager::getInstance()
->get('MagentoFrameworkAppResourceConnection');
$connection = $this->_resources->getConnection();
$table = $this->_resources->getTableName('order_fullfill');
But when I am calling a method from cron job suppose init()
, how would I initilize $this->orderRepository
and $this->scopeConfig
.
function init()
$this->orderRepository = $this->ObjectManager->get('MagentoSalesApiOrderRepository');
$this->scopeConfig = MagentoFrameworkAppConfigScopeConfigInterfaceobjectManager::getInstance();
$this->_resources = MagentoFrameworkAppObjectManager::getInstance()
->get('MagentoFrameworkAppResourceConnection');
$connection = $this->_resources->getConnection();
$table = $this->_resources->getTableName('order_fullfill');
Thanks
magento2 php event-observer
add a comment |
I need to call API after user place order.
My issue is when my event method called after placing order it initializes variables as shown in the constructor.
public function __construct(
OrderRepositoryInterface $OrderRepositoryInterface , ScopeConfigInterface
$scopeConfig
)
$this->orderRepository = $OrderRepositoryInterface;
$this->scopeConfig = $scopeConfig;
$this->_resources = MagentoFrameworkAppObjectManager::getInstance()
->get('MagentoFrameworkAppResourceConnection');
$connection = $this->_resources->getConnection();
$table = $this->_resources->getTableName('order_fullfill');
But when I am calling a method from cron job suppose init()
, how would I initilize $this->orderRepository
and $this->scopeConfig
.
function init()
$this->orderRepository = $this->ObjectManager->get('MagentoSalesApiOrderRepository');
$this->scopeConfig = MagentoFrameworkAppConfigScopeConfigInterfaceobjectManager::getInstance();
$this->_resources = MagentoFrameworkAppObjectManager::getInstance()
->get('MagentoFrameworkAppResourceConnection');
$connection = $this->_resources->getConnection();
$table = $this->_resources->getTableName('order_fullfill');
Thanks
magento2 php event-observer
add a comment |
I need to call API after user place order.
My issue is when my event method called after placing order it initializes variables as shown in the constructor.
public function __construct(
OrderRepositoryInterface $OrderRepositoryInterface , ScopeConfigInterface
$scopeConfig
)
$this->orderRepository = $OrderRepositoryInterface;
$this->scopeConfig = $scopeConfig;
$this->_resources = MagentoFrameworkAppObjectManager::getInstance()
->get('MagentoFrameworkAppResourceConnection');
$connection = $this->_resources->getConnection();
$table = $this->_resources->getTableName('order_fullfill');
But when I am calling a method from cron job suppose init()
, how would I initilize $this->orderRepository
and $this->scopeConfig
.
function init()
$this->orderRepository = $this->ObjectManager->get('MagentoSalesApiOrderRepository');
$this->scopeConfig = MagentoFrameworkAppConfigScopeConfigInterfaceobjectManager::getInstance();
$this->_resources = MagentoFrameworkAppObjectManager::getInstance()
->get('MagentoFrameworkAppResourceConnection');
$connection = $this->_resources->getConnection();
$table = $this->_resources->getTableName('order_fullfill');
Thanks
magento2 php event-observer
I need to call API after user place order.
My issue is when my event method called after placing order it initializes variables as shown in the constructor.
public function __construct(
OrderRepositoryInterface $OrderRepositoryInterface , ScopeConfigInterface
$scopeConfig
)
$this->orderRepository = $OrderRepositoryInterface;
$this->scopeConfig = $scopeConfig;
$this->_resources = MagentoFrameworkAppObjectManager::getInstance()
->get('MagentoFrameworkAppResourceConnection');
$connection = $this->_resources->getConnection();
$table = $this->_resources->getTableName('order_fullfill');
But when I am calling a method from cron job suppose init()
, how would I initilize $this->orderRepository
and $this->scopeConfig
.
function init()
$this->orderRepository = $this->ObjectManager->get('MagentoSalesApiOrderRepository');
$this->scopeConfig = MagentoFrameworkAppConfigScopeConfigInterfaceobjectManager::getInstance();
$this->_resources = MagentoFrameworkAppObjectManager::getInstance()
->get('MagentoFrameworkAppResourceConnection');
$connection = $this->_resources->getConnection();
$table = $this->_resources->getTableName('order_fullfill');
Thanks
magento2 php event-observer
magento2 php event-observer
edited 2 days ago
Muhammad Anas
192114
192114
asked Aug 17 '17 at 13:38
bhupinderbhupinder
53
53
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You don't need to worry about because ObjectManager
takes care of it for you in the background.
Besides using ObjectManager
directly is considered a bad practice. Instead, initialise OrderInterface
in the constructor of your cron class and then use it in your method.
Example:
/**
* @var MagentoSalesApiDataOrderInterface
*/
private $order;
/**
* @param MagentoSalesApiDataOrderInterface $order
*/
public function __construct(
MagentoSalesApiDataOrderInterface $order
)
$this->order = $order;
public function youMethod()
$billingAddress = $this->order->getBillingAddress();
return $billingAddress;
add a comment |
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%2f189517%2faccess-orderrepositoryinterface-interface-from-cron-job%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 don't need to worry about because ObjectManager
takes care of it for you in the background.
Besides using ObjectManager
directly is considered a bad practice. Instead, initialise OrderInterface
in the constructor of your cron class and then use it in your method.
Example:
/**
* @var MagentoSalesApiDataOrderInterface
*/
private $order;
/**
* @param MagentoSalesApiDataOrderInterface $order
*/
public function __construct(
MagentoSalesApiDataOrderInterface $order
)
$this->order = $order;
public function youMethod()
$billingAddress = $this->order->getBillingAddress();
return $billingAddress;
add a comment |
You don't need to worry about because ObjectManager
takes care of it for you in the background.
Besides using ObjectManager
directly is considered a bad practice. Instead, initialise OrderInterface
in the constructor of your cron class and then use it in your method.
Example:
/**
* @var MagentoSalesApiDataOrderInterface
*/
private $order;
/**
* @param MagentoSalesApiDataOrderInterface $order
*/
public function __construct(
MagentoSalesApiDataOrderInterface $order
)
$this->order = $order;
public function youMethod()
$billingAddress = $this->order->getBillingAddress();
return $billingAddress;
add a comment |
You don't need to worry about because ObjectManager
takes care of it for you in the background.
Besides using ObjectManager
directly is considered a bad practice. Instead, initialise OrderInterface
in the constructor of your cron class and then use it in your method.
Example:
/**
* @var MagentoSalesApiDataOrderInterface
*/
private $order;
/**
* @param MagentoSalesApiDataOrderInterface $order
*/
public function __construct(
MagentoSalesApiDataOrderInterface $order
)
$this->order = $order;
public function youMethod()
$billingAddress = $this->order->getBillingAddress();
return $billingAddress;
You don't need to worry about because ObjectManager
takes care of it for you in the background.
Besides using ObjectManager
directly is considered a bad practice. Instead, initialise OrderInterface
in the constructor of your cron class and then use it in your method.
Example:
/**
* @var MagentoSalesApiDataOrderInterface
*/
private $order;
/**
* @param MagentoSalesApiDataOrderInterface $order
*/
public function __construct(
MagentoSalesApiDataOrderInterface $order
)
$this->order = $order;
public function youMethod()
$billingAddress = $this->order->getBillingAddress();
return $billingAddress;
edited Aug 17 '17 at 14:11
answered Aug 17 '17 at 13:59
diazwatsondiazwatson
1,57811425
1,57811425
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%2f189517%2faccess-orderrepositoryinterface-interface-from-cron-job%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