From 91dbc83cbb5917e12ec646ce57bb7dfee23f4573 Mon Sep 17 00:00:00 2001 From: Cid Lopes Date: Tue, 31 Oct 2023 12:58:53 +0200 Subject: [PATCH 1/5] Add full category ids breadcrumb to path --- Model/Category/Builder.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Model/Category/Builder.php b/Model/Category/Builder.php index f8abe18a9..c456b98d7 100644 --- a/Model/Category/Builder.php +++ b/Model/Category/Builder.php @@ -91,9 +91,9 @@ public function build(Category $category, Store $store) $nostoCategory->setId($category->getId()); $nostoCategory->setParentId($category->getParentId()); $nostoCategory->setTitle($this->getCategoryNameById($category->getId(), $store->getId())); - $path = $this->nostoCategoryService->getCategory($category, $store); - $nostoCategory->setPath($path ?? ''); - $nostoCategory->setCategoryString($path ?? ''); + $pathString = $this->nostoCategoryService->getCategory($category, $store); + $nostoCategory->setPath($category->getPath() ?? ''); + $nostoCategory->setCategoryString($pathString ?? ''); $nostoCategory->setUrl($category->getUrl()); $nostoCategory->setAvailable($category->getIsActive() ?? false); } catch (Exception $e) { From 4ebeb079b35abd9089821ba393c7fff69705efe9 Mon Sep 17 00:00:00 2001 From: Cid Lopes Date: Thu, 1 Feb 2024 11:49:00 -0300 Subject: [PATCH 2/5] Add category parent ids to product data & tagging --- Model/Product/Builder.php | 4 ++++ .../Product/Category/CachingCategoryService.php | 5 +++++ .../Product/Category/DefaultCategoryService.php | 16 ++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/Model/Product/Builder.php b/Model/Product/Builder.php index 422e646d7..a9cae9432 100644 --- a/Model/Product/Builder.php +++ b/Model/Product/Builder.php @@ -224,6 +224,10 @@ public function build( $nostoProduct->setAvailability($this->buildAvailability($product, $store)); $nostoProduct->setCategories($this->nostoCategoryService->getCategories($product, $store)); $nostoProduct->setCategoryIds($product->getCategoryIds()); + $nostoProduct->setParentCategoryIds( + $this->nostoCategoryService->getCategoryParentIds($product, $store) + ); + if ($this->nostoDataHelper->isInventoryTaggingEnabled($store)) { $inventoryLevel = $this->stockService->getQuantity($product, $store); $nostoProduct->setInventoryLevel($inventoryLevel); diff --git a/Model/Service/Product/Category/CachingCategoryService.php b/Model/Service/Product/Category/CachingCategoryService.php index ec419439f..2a86f0d3d 100644 --- a/Model/Service/Product/Category/CachingCategoryService.php +++ b/Model/Service/Product/Category/CachingCategoryService.php @@ -85,4 +85,9 @@ public function getCategories(Product $product, StoreInterface $store) { return $this->categoryService->getCategories($product, $store); } + + public function getCategoryParentIds(Product $product, StoreInterface $store) + { + return $this->categoryService->getCategoryParentIds($product, $store); + } } diff --git a/Model/Service/Product/Category/DefaultCategoryService.php b/Model/Service/Product/Category/DefaultCategoryService.php index 316e16823..79c611949 100644 --- a/Model/Service/Product/Category/DefaultCategoryService.php +++ b/Model/Service/Product/Category/DefaultCategoryService.php @@ -138,4 +138,20 @@ public function getCategory(Category $category, StoreInterface $store) return $nostoCategory; } + + /** + * @param Product $product + * @param StoreInterface $store + * @return array + */ + public function getCategoryParentIds(Product $product, StoreInterface $store) + { + $parentCategoriesIds = []; + foreach ($product->getCategoryCollection()->setStore($store->getId()) as $category) { + foreach ($category->getParentIds() as $parentId) { + $parentCategoriesIds[] = $parentId; + } + } + return array_values(array_unique($parentCategoriesIds)); // Sequential keys to avoid serialization issues + } } From e1e23635409d2e4c625afbe7a83b96225993b239 Mon Sep 17 00:00:00 2001 From: Cid Lopes Date: Thu, 8 Feb 2024 14:42:39 -0300 Subject: [PATCH 3/5] Bump php-sdk --- composer.json | 2 +- composer.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 965f6459a..4717789f1 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "php": ">=7.4.0", "magento/framework": ">=101.0.6|~104.0", "ext-json": "*", - "nosto/php-sdk": "^7.1", + "nosto/php-sdk": "^7.3", "laminas/laminas-uri": "*" }, "repositories": [ diff --git a/composer.lock b/composer.lock index ccc182732..5ca043da1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "bf7fe6548f1a69f404bf4e4f4b2cd27e", + "content-hash": "cc92a380a8b805a1f582fac9f0ce1d2b", "packages": [ { "name": "brick/math", @@ -2862,16 +2862,16 @@ }, { "name": "nosto/php-sdk", - "version": "7.2.0", + "version": "7.3.0", "source": { "type": "git", "url": "https://github.com/Nosto/nosto-php-sdk.git", - "reference": "efe6218e43bf08b41ca9500b9b1434d1de25e564" + "reference": "9588f93424490daf8c2b174842254f63bad0a945" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Nosto/nosto-php-sdk/zipball/efe6218e43bf08b41ca9500b9b1434d1de25e564", - "reference": "efe6218e43bf08b41ca9500b9b1434d1de25e564", + "url": "https://api.github.com/repos/Nosto/nosto-php-sdk/zipball/9588f93424490daf8c2b174842254f63bad0a945", + "reference": "9588f93424490daf8c2b174842254f63bad0a945", "shasum": "" }, "require": { @@ -2912,9 +2912,9 @@ "description": "PHP SDK for developing Nosto modules for e-commerce platforms", "support": { "issues": "https://github.com/Nosto/nosto-php-sdk/issues", - "source": "https://github.com/Nosto/nosto-php-sdk/tree/7.2.0" + "source": "https://github.com/Nosto/nosto-php-sdk/tree/7.3.0" }, - "time": "2023-11-23T15:12:57+00:00" + "time": "2024-02-08T14:56:42+00:00" }, { "name": "paragonie/constant_time_encoding", From 01a0bc058d5e99229ff215777ba82c693509869f Mon Sep 17 00:00:00 2001 From: Cid Lopes Date: Thu, 8 Feb 2024 14:53:27 -0300 Subject: [PATCH 4/5] Fix phan warnings --- Model/Service/Product/Category/CachingCategoryService.php | 3 +++ .../Service/Product/Category/CategoryServiceInterface.php | 7 +++++++ Model/Service/Product/Category/DefaultCategoryService.php | 1 + 3 files changed, 11 insertions(+) diff --git a/Model/Service/Product/Category/CachingCategoryService.php b/Model/Service/Product/Category/CachingCategoryService.php index 2a86f0d3d..48353dc70 100644 --- a/Model/Service/Product/Category/CachingCategoryService.php +++ b/Model/Service/Product/Category/CachingCategoryService.php @@ -86,6 +86,9 @@ public function getCategories(Product $product, StoreInterface $store) return $this->categoryService->getCategories($product, $store); } + /** + * @inheritDoc + */ public function getCategoryParentIds(Product $product, StoreInterface $store) { return $this->categoryService->getCategoryParentIds($product, $store); diff --git a/Model/Service/Product/Category/CategoryServiceInterface.php b/Model/Service/Product/Category/CategoryServiceInterface.php index 52f02ee70..18f825b0d 100644 --- a/Model/Service/Product/Category/CategoryServiceInterface.php +++ b/Model/Service/Product/Category/CategoryServiceInterface.php @@ -55,4 +55,11 @@ public function getCategory(Category $category, StoreInterface $store); * @return array */ public function getCategories(Product $product, StoreInterface $store); + + /** + * @param Product $product + * @param StoreInterface $store + * @return array + */ + public function getCategoryParentIds(Product $product, StoreInterface $store); } diff --git a/Model/Service/Product/Category/DefaultCategoryService.php b/Model/Service/Product/Category/DefaultCategoryService.php index 79c611949..3bd9a1b30 100644 --- a/Model/Service/Product/Category/DefaultCategoryService.php +++ b/Model/Service/Product/Category/DefaultCategoryService.php @@ -147,6 +147,7 @@ public function getCategory(Category $category, StoreInterface $store) public function getCategoryParentIds(Product $product, StoreInterface $store) { $parentCategoriesIds = []; + /** @phan-suppress-next-line PhanUndeclaredMethod */ foreach ($product->getCategoryCollection()->setStore($store->getId()) as $category) { foreach ($category->getParentIds() as $parentId) { $parentCategoriesIds[] = $parentId; From d9c2c2eebfeeef2529556b0a94cad5c86a49c967 Mon Sep 17 00:00:00 2001 From: Cid Lopes Date: Wed, 6 Mar 2024 11:30:29 +0200 Subject: [PATCH 5/5] Bump version and update changelog --- CHANGELOG.md | 3 +++ composer.json | 2 +- etc/module.xml | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df754f8b6..43a5ea6b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning. +### 7.5.0 +* Add category parent id to tagging and product data + ### 7.4.0 * Replace deprecated Zend_db_select usage * Update Yotpo compatibility to > 4.1 and remove < 3.3 diff --git a/composer.json b/composer.json index 4717789f1..452d43803 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "nosto/module-nostotagging", "description": "Increase your conversion rate and average order value by delivering your customers personalized product recommendations throughout their shopping journey.", "type": "magento2-module", - "version": "7.4.0", + "version": "7.5.0", "require-dev": { "phpmd/phpmd": "^2.5", "sebastian/phpcpd": "*", diff --git a/etc/module.xml b/etc/module.xml index d510752de..0160e20d8 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -37,5 +37,5 @@ - +