Skip to content

Commit

Permalink
Add parentCategoryIds to product object
Browse files Browse the repository at this point in the history
  • Loading branch information
supercid committed Feb 1, 2024
1 parent ea77a25 commit edc5408
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/Model/Product/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,15 @@ class Product extends AbstractObject implements
private $categories;

/**
* @var StringCollection collection of product category strings.
* @var StringCollection collection of product category ids strings.
*/
private $categoryIds;

/**
* @var StringCollection product parent categories ids.
*/
private $parentCategoryIds;

/**
* @var string the product description.
*/
Expand Down Expand Up @@ -266,6 +271,7 @@ public function __construct()
$this->alternateImageUrls = new StringCollection('alternate_image_urls', 'alternate_image_url');
$this->categories = new StringCollection('categories', 'category');
$this->categoryIds = new StringCollection('category_ids', 'category_id');
$this->parentCategoryIds = new StringCollection('parent_categories', 'parent_category_id');
}

/**
Expand Down Expand Up @@ -595,6 +601,26 @@ public function setCategoryIds(array $categoryIds)
$this->categoryIds->setData($categoryIds);
}

/**
* Sets the product parent category ids.
*
* @param array $parentCategoryIds the list of parent category ids.
*/
public function setParentCategoryIds(array $parentCategoryIds)
{
$this->parentCategoryIds->setData($parentCategoryIds);
}

/**
* Returns the product parent category ids
*
* @return array
*/
public function getParentCategoryIds()
{
return $this->parentCategoryIds->getData();
}

/**
* Adds a category to the product.
*
Expand Down
7 changes: 7 additions & 0 deletions src/Types/Product/ProductInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ public function getCategories();
*/
public function getCategoryIds();

/**
* Returns the parent categories of the product.
*
* @return string
*/
public function getParentCategoryIds();

/**
* Returns the product description.
*
Expand Down

0 comments on commit edc5408

Please sign in to comment.