I'm trying to add an extension attribute to my order entity.

I've follewed this link : https://www.rakeshjesadiya.com/extension-attribute-in-order-data-magento-2/

But I can see my extension attribute in my backend order entity.

Also, for the /sales/order/history, i've this :

    public function getOrders()
    if (!($customerId = $this->_customerSession->getCustomerId())) {
        return false;
    if (!$this->orders) {
        $this->orders = $this->getOrderCollectionFactory()->create($customerId)->addFieldToSelect(
            ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]
        )->addFieldToFilter('my_attribute', array("eq" => "Some value"))
            ->addFieldToFilter("category_ids", array("nin" => 9))
    return $this->orders;

But I have this error :

Column not found: 1054 Unknown column 'my_attribute' in 'where clause', query was: SELECT COUNT(*) FROM sales_order AS main_table WHERE (main_table.customer_id = '70') AND (status IN('canceled', 'closed', 'complete', 'fraud', 'fraud', 'holded', 'payment_review', 'pending', 'processing')) AND (my_attribute = 'Some value') AND (category_ids NOT IN(9)) [] []

I need this because I need to hide orders where the orders contain certains category of product, if you know how to to this it woul be great !

1 Answer 1


Extension attributes are not custom attributes. You have to personally handle their persistence (create a column|table for them in the database and save|load them).

More about this in the Official docs and an example here Magento Official Github Example documented here

Another comprehensive tutorial can be found here

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.