Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/7.5.0 #845

Merged
merged 7 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions Model/Category/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions Model/Product/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions Model/Service/Product/Category/CachingCategoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,12 @@ 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);
}
}
7 changes: 7 additions & 0 deletions Model/Service/Product/Category/CategoryServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
17 changes: 17 additions & 0 deletions Model/Service/Product/Category/DefaultCategoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,21 @@ 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 = [];
/** @phan-suppress-next-line PhanUndeclaredMethod */
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
}
}
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "*",
Expand Down Expand Up @@ -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": [
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
<!--suppress XmlUnboundNsPrefix -->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Nosto_Tagging" setup_version="7.4.0"/>
<module name="Nosto_Tagging" setup_version="7.5.0"/>
</config>
Loading