Frage

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

War es hilfreich?

Lösung

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;
     
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top