0

I want to retrieve orders of a specific store? Is there any way to achieve it. R&D just gave me methods to get store id from order or get store/customer information using order. But i have not found anything which helps me to fetch the orders collection of a specific store

2

In your constructor, import

\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory

and set

$this->_orderCollectionFactory = $orderCollectionFactory;

and if you already have a way of obtaining the store ID you should be able to call it by passing it in like:

public function getOrderCollectionByStoreId($storeId)
{

    $collection = $this->_orderCollectionFactory->create()
       ->addAttributeToSelect('*')
       ->addFieldToFilter('store_id', $storeId);
     
    return $collection;
     
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.