From 843ce7addaaa94f829cb44a1700abf63f4582718 Mon Sep 17 00:00:00 2001 From: Kirill Morozov Date: Sat, 11 May 2019 04:01:41 +0300 Subject: [PATCH] SIM-1: Make sure base product shows up first. --- Helper/Api.php | 14 ++++++++------ Plugin/Catalog/Model/Product.php | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Helper/Api.php b/Helper/Api.php index a1209ae..396669a 100644 --- a/Helper/Api.php +++ b/Helper/Api.php @@ -1,13 +1,14 @@ resourceConnection = $resourceConnection; $this->similarityHelper = $similarityHelper; $this->productHelper = $productHelper; @@ -41,7 +43,7 @@ public function __construct( /** * Service ==> Magento */ - public function getUpSells($productId) + public function getUpSells($productId, $showTarget = true) { $url = $this->similarityHelper->getUrl() . sprintf(self::PATH_GET_UPSELLS, $productId); $ctxParams = []; @@ -63,7 +65,7 @@ public function getUpSells($productId) $items = \Zend_Json::decode($response); // error $tempArr = []; foreach ($items as $item) { - if ($item[1] > 0.0000001) { + if ( $item[1] > 0.0000001 || $showTarget) { $tempArr[$item[0][0]['entity_id']] = $item[0][0]['image'] . $item[1]; } } diff --git a/Plugin/Catalog/Model/Product.php b/Plugin/Catalog/Model/Product.php index d750a30..aadb8b9 100644 --- a/Plugin/Catalog/Model/Product.php +++ b/Plugin/Catalog/Model/Product.php @@ -26,7 +26,7 @@ public function aroundGetUpSellProductCollection( { if ($this->defaultHelper->canUse()) { try { - if ($ids = $this->apiHelper->getUpSells($product->getEntityId())) { + if ($ids = $this->apiHelper->getUpSells($product->getEntityId(), false)) { $productCollection = $this->collectionFactory->create(); $productCollection ->addAttributeToFilter('entity_id', ['in' => $ids])