/** * @param \Magento\Catalog\Model\Resource\Product\Collection $collection * @throws \Magento\Framework\Exception\LocalizedException */ protected function _joinInventoryFields(\Magento\Catalog\Model\Resource\Product\Collection $collection) { if (!empty($this->_inventoryFields) && $this->moduleManager->isEnabled('Magento_CatalogInventory')) { foreach ($this->_inventoryFields as $field) { $collection->joinField($field, 'cataloginventory_stock_item', $field, 'product_id=entity_id', '{{table}}.stock_id=1', 'left'); } } }