0

Magento 2 EE version provide default Order By SKU widget but it's not working with default luma theme please check attached screenshot.

enter image description here

Steps

Go to Admin => Content => pages => home page => add Order By SKU widget

I have facing this in Magento EE 2.3.5 and Magento EE 2.4.0

Thank you for your help.

2 Answers 2

0

I don't know about magento core implementation of the functionnality, but I'm using a custom method to do this. Feel free to call the result in a custom template and to adopt the data returned in the array.

/**
 * @return array|string
 */
public function getCollectionOrders()
{
    if ($this->getRequest()->getParam('sku')) {
        $sku = $this->getRequest()->getParam('sku');
        $collection = $this->_orderCollectionFactory->create()
            ->addAttributeToSelect('*');

        $collection->getSelect()
            ->join(
                ["soi" => $collection->getTable("sales_order_item")],
                'main_table.entity_id = soi.order_id',
                array('sku')
            )
            ->where("soi.sku like = ? ", $sku);

        $collection->setOrder(
            'created_at',
            'desc'
        );

        $arrayOrders = array();

        foreach ($collection as $order) {
            $arrayOrders[] = array(
                'entity_id' => $order->getEntityId(),
                'id' => $order->getIncrementId(),
                'billing' => $order->getBillingAddress()->getLastname() . ' ' . $order->getBillingAddress()->getFirstname(),
                'shipping' => $order->getShippingAddress()->getLastname() . ' ' . $order->getShippingAddress()->getFirstname(),
                'status' => $order->getStatus(),
                'sku' => $sku
            );
        }

        return $arrayOrders;
    }

    return '';
}
0

have you ever able to solve this problem. for me its working on one store but showing same error as yours on other store.

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.