Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with loading order via loadByIncrementId #3534

Closed
Grohotun opened this issue Feb 24, 2016 · 2 comments
Closed

Error with loading order via loadByIncrementId #3534

Grohotun opened this issue Feb 24, 2016 · 2 comments
Assignees

Comments

@Grohotun
Copy link
Contributor

\Magento\Sales\Model\OrderFactory $orderFactory

$order = $this->_orderFactory->create()->loadByIncrementId(000000013)

echo $order->getId();

returns 11 (but not 13)

But in sales_order - all is good.

If echo $order->getPayment()->getMethodInstance()->getCode() - result is 'substitution' - method, which was never used.

2016-02-24 19 22 26

@Mulderua
Copy link
Contributor

Mulderua commented Jun 21, 2016

Hi @Grohotun, we cannot reproduce your issue.
For properly data retrieving you should use \Magento\Sales\Model\OrderRepository::getList(\Magento\Framework\Api\SearchCriteria $searchCriteria) and Magento\Framework\Api\SearchCriteriaBuilder

For example

$searchCriteria = $this->searchCriteriaBuilder->addFilter('increment_id', '000000001', 'eq')->create();
$orderList = $this->orderRepository->getList($searchCriteria);
echo $orderList->getFirstItem()->getIncrementId();

Repositories are the best way to work with data in Magento 2.

@Grohotun
Copy link
Contributor Author

Hi, @Mulderua
I've just tested on 2.0.6 version - my code works well.
So, I think, that was bug in 2.0.2 version and it was somehow fixed.

magento-engcom-team pushed a commit that referenced this issue Dec 14, 2018
[TSG] Backporting for 2.2 (pr63) (2.2.8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants