diff --git a/vendor/magento/module-purchase-order/Plugin/Quote/ExpiredQuotesCollectionFilter.php b/vendor/magento/module-purchase-order/Plugin/Quote/ExpiredQuotesCollectionFilter.php new file mode 100644 index 0000000000..54510ebe51 --- /dev/null +++ b/vendor/magento/module-purchase-order/Plugin/Quote/ExpiredQuotesCollectionFilter.php @@ -0,0 +1,80 @@ +purchaseOrderResource = $purchaseOrderResource; + $this->config = $config; + $this->websiteRepository = $websiteRepository; + } + + /** + * Add filter to the expired quotes collection + * + * @param ExpiredQuotesCollection $subject + * @param AbstractCollection $result + * @param StoreInterface $store + * @return AbstractCollection + * @throws LocalizedException + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function afterGetExpiredQuotes( + ExpiredQuotesCollection $subject, + AbstractCollection $result, + StoreInterface $store + ): AbstractCollection { + $website = $this->websiteRepository->getById($store->getWebsiteId()); + if ($this->config->isEnabledForWebsite($website)) { + $result->getSelect()->joinLeft( + ['po' => $this->purchaseOrderResource->getTable($this->purchaseOrderResource->getMainTable())], + 'po.quote_id = main_table.entity_id', + 'po.quote_id' + ); + $result->addFieldToFilter('po.entity_id', ['null' => true]); + } + + return $result; + } +} diff --git a/vendor/magento/module-purchase-order/etc/di.xml b/vendor/magento/module-purchase-order/etc/di.xml index acdc58579d..893e294d7b 100644 --- a/vendor/magento/module-purchase-order/etc/di.xml +++ b/vendor/magento/module-purchase-order/etc/di.xml @@ -316,4 +316,7 @@ + + +