How to fix «Unknown column 'stock_status_index.qty' in 'order clause'» for Amasty Improved Sorting in Magento 2.3 with Multi Stock Inventory (MSI) enabled?

magento23
amasty
multi-stock-inventory

(Dmitry Fedyuk) #1

Locate the method \Amasty\Sorting\Model\ResourceModel\Method\Instock::apply().

Replace the line

'stock_status_index.qty > ' . $this->helper->getQtyOutStock() . ' OR e.type_id in (' . implode(

to

sprintf('stock_status_index.%s > ',
	\Magento\Framework\App\ObjectManager::getInstance()
		->get(\Magento\Framework\Module\Manager::class)
			->isEnabled('Magento_Inventory')
	? 'quantity' : 'qty'
)
. $this->helper->getQtyOutStock() . ' OR e.type_id in (' . implode(