I have a Custom attribute name ( product string ) on Product in which i have save a string i want to get those orders which will have that product string of same value.

I will get the product by :

$collection = $this->_orderCollectionFactory->create()
return $collection;

1 Answer 1


Get the collection in your block file

public function getOrderCollection()
        $collection = $this->_orderCollectionFactory->create();           
        $collection->addAttributeToFilter('your_attribute_code_here', 1);
        return $collection; 

now call this collection in your phtml file

  • I am getting error Exception #0 (Zend_Db_Statement_Exception): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'custom_attribute' in 'where clause', query was: SELECT main_table.* FROM sales_order AS main_table WHERE (custom_attribute = 'test_string') ORDER BY created_at DESC @Chikku
    – Prits
    Commented Aug 10, 2020 at 17:08
  • Actually i want to use order and product collection togather.
    – Prits
    Commented Aug 10, 2020 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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