Skip to content

getOrderCollectionFactory with only orders containing specify Attribute Set – Magento2.4

We would like to create our own getOrderCollectionFactory based on MagentoSalesOrderHistory, with only orders containing specify Attribute Set.

How can we extend the addFieldToFilter part?

public function getOrders()
{
    if (!($customerId = $this->_customerSession->getCustomerId())) {
        return false;
    }
    if (!$this->orders) {
        $this->orders = $this->getOrderCollectionFactory()->create($customerId)->addFieldToSelect(
            '*'
        )->addFieldToFilter(
            'status',
            ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()]
        )->setOrder(
            'created_at',
            'desc'
        );
    }
    return $this->orders;
}