I want to Filter Orders based on Shipping country I have filtered using other attributes like grand_base_total and store_id but struck at shipping country as there is no any attribute for that in sales_order table

  • Can you add your code for order collection ?So that I can add filter as per your requirement – ParulThakkar Jun 16 '20 at 7:31
  • I want to get only those order which has country_id = 'US – User 69 Jun 16 '20 at 7:40
  • yes but can you add your collection query ? – ParulThakkar Jun 16 '20 at 8:01
  • @ParulThakkar I have done this please check my answer and let me know is it the right way to do this? – User 69 Jun 16 '20 at 11:51

I have done this using one of the clues from M1 Question

protected $_orderCollectionFactory;

public function __construct(
    \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
) {
    $this->_orderCollectionFactory = $orderCollectionFactory;
public function getOrderCollection()
      $collection = $this->_orderCollectionFactory->create()
            /* Joined with `sales_order_address` to get COuntry Id */
                'sales_order_address.country_id ')
            /* Added `country_id` Filter */
                array('IN' => 'US,UK')
        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.