Skip to content

Commit

Permalink
Merge pull request #356 from Nosto/feature/category-parent-ids
Browse files Browse the repository at this point in the history
add parent category id's to tagging and API
  • Loading branch information
supercid authored Mar 7, 2024
2 parents 5c2065f + d9ec37a commit 44bb8b9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
15 changes: 15 additions & 0 deletions classes/models/NostoProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public static function loadData(Product $product)
$nostoProduct->setAvailability(self::checkAvailability($product));
$nostoProduct->amendTags($product);
$nostoProduct->amendCategories($product);
$nostoProduct->amendParentCategories($product);
$nostoProduct->setDescription($product->description_short . $product->description);
$nostoProduct->setInventoryLevel((int)$product->quantity);
$nostoProduct->amendBrand($product);
Expand Down Expand Up @@ -355,6 +356,20 @@ protected function amendCategories(Product $product)
}
}

/**
* Fetches the parent category id's
*
* @param Product $product the product model.
*/
protected function amendParentCategories(Product $product)
{
$parentCategories = [];
foreach ($product->getParentCategories(NostoHelperContext::getLanguageId()) as $parentCategory) {
$parentCategories[] = $parentCategory['id_parent'];
}
$this->setParentCategoryIds(array_values(array_unique($parentCategories)));
}

/**
* Builds the brand name from the product's manufacturer to and returns them.
*
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"AFL-3.0"
],
"require": {
"nosto/php-sdk": "^7.1",
"nosto/php-sdk": "^7.3",
"ext-json": "*"
},
"require-dev": {
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.

0 comments on commit 44bb8b9

Please sign in to comment.