From 9dcca7aeee2c9b49cf5c1996a82a934b3df21af9 Mon Sep 17 00:00:00 2001 From: sergey Date: Wed, 18 Dec 2019 15:31:24 +0300 Subject: [PATCH] hide "Add to Cart" button in search popup for unavailable products --- Model/Search/Product.php | 25 ++++++++++++++----------- changelog.md | 6 +++++- composer.json | 4 ++-- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Model/Search/Product.php b/Model/Search/Product.php index 3f03aca..dc2fb53 100755 --- a/Model/Search/Product.php +++ b/Model/Search/Product.php @@ -131,22 +131,25 @@ protected function getProductCollection($queryText) */ protected function getProductData($product) { - /** @var \MageWorx\SearchSuiteAutocomplete\Block\Autocomplete\Product $product */ - $product = $this->objectManager->create('MageWorx\SearchSuiteAutocomplete\Block\Autocomplete\ProductAgregator') + /** @var \MageWorx\SearchSuiteAutocomplete\Block\Autocomplete\ProductAgregator $productAgregator */ + $productAgregator = $this->objectManager->create('MageWorx\SearchSuiteAutocomplete\Block\Autocomplete\ProductAgregator') ->setProduct($product); $data = [ - ProductFields::NAME => $product->getName(), - ProductFields::SKU => $product->getSku(), - ProductFields::IMAGE => $product->getSmallImage(), - ProductFields::REVIEWS_RATING => $product->getReviewsRating(), - ProductFields::SHORT_DESCRIPTION => $product->getShortDescription(), - ProductFields::DESCRIPTION => $product->getDescription(), - ProductFields::PRICE => $product->getPrice(), - ProductFields::ADD_TO_CART => $product->getAddToCartData(), - ProductFields::URL => $product->getUrl() + ProductFields::NAME => $productAgregator->getName(), + ProductFields::SKU => $productAgregator->getSku(), + ProductFields::IMAGE => $productAgregator->getSmallImage(), + ProductFields::REVIEWS_RATING => $productAgregator->getReviewsRating(), + ProductFields::SHORT_DESCRIPTION => $productAgregator->getShortDescription(), + ProductFields::DESCRIPTION => $productAgregator->getDescription(), + ProductFields::PRICE => $productAgregator->getPrice(), + ProductFields::URL => $productAgregator->getUrl() ]; + if ($product->getData('is_salable')) { + $data[ProductFields::ADD_TO_CART] = $productAgregator->getAddToCartData(); + } + return $data; } diff --git a/changelog.md b/changelog.md index 9a660d3..f134258 100644 --- a/changelog.md +++ b/changelog.md @@ -2,4 +2,8 @@ ### Version 2.1.4 -- **Fix**: Update locale file \ No newline at end of file +- **Fix**: Update locale file + +### Version 2.1.4 + +- **Fix**: Hide "Add to Cart" button in search popup for unavailable products \ No newline at end of file diff --git a/composer.json b/composer.json index a6ba3c4..ca9bbc5 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "magento/module-search": ">=100.0.0 <102" }, "type": "magento2-module", - "version": "2.1.8", + "version": "2.1.9", "license": "GPL-3.0", "authors": [ { @@ -25,4 +25,4 @@ "MageWorx\\SearchSuiteAutocomplete\\": "" } } -} +} \ No newline at end of file