Skip to content

Commit

Permalink
[FIX] Product ID null.
Browse files Browse the repository at this point in the history
  • Loading branch information
Seiger committed May 17, 2024
1 parent 61166bb commit cbeb08c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions docs/pages/integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This method will return the searched category along with the recursively constru
Nesting depth depends on the `$dept` parameter (default 10).

```php
EvolutionCMS\Models\SiteContent {#1902 ▼
Seiger\sCommerce\Models\sCategory {#1902 ▼
#connection: "default"
#table: "site_content"
...
Expand All @@ -26,17 +26,17 @@ EvolutionCMS\Models\SiteContent {#1902 ▼
...
"subcategories" => EvolutionCMS\Extensions\Collection {#1889 ▼
#items: array:4 [▼
0 => EvolutionCMS\Models\SiteContent {#1888 ▼
0 => Seiger\sCommerce\Models\sCategory {#1888 ▼
#connection: "default"
#table: "site_content"
...
#attributes: array:37 [▶]
#original: array:36 [▶]
...
}
1 => EvolutionCMS\Models\SiteContent {#1886 ▶}
2 => EvolutionCMS\Models\SiteContent {#1884 ▶}
3 => EvolutionCMS\Models\SiteContent {#1882 ▶}
1 => Seiger\sCommerce\Models\sCategory {#1886 ▶}
2 => Seiger\sCommerce\Models\sCategory {#1884 ▶}
3 => Seiger\sCommerce\Models\sCategory {#1882 ▶}
]
#escapeWhenCastingToString: false
}
Expand Down
2 changes: 1 addition & 1 deletion module/sCommerceModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@
}
}

$product = sCommerce::getProduct($content->product);
$product = sCommerce::getProduct($content->product ?? 0);
$categoryParentsIds = [0];
if ($product->category) {
$categoryParentsIds = $sCommerceController->categoryParentsIds($product->category);
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/sCommerceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,8 @@ protected function getParentsIds(int $categoryId): array
if ($categoryId != evo()->getConfig('catalog_root', evo()->getConfig('site_start', 1))) {
$category = sCategory::find($categoryId);
$parent = $category->getParent();
$this->categories = array_merge($this->categories, [$parent->id]);
if ($parent->id && $categoryId != evo()->getConfig('catalog_root', evo()->getConfig('site_start', 1))) {
$this->categories = array_merge($this->categories, [$parent->id ?? 0]);
if (($parent->id ?? 0) && $categoryId != evo()->getConfig('catalog_root', evo()->getConfig('site_start', 1))) {
$this->categories = $this->getParentsIds($parent->id);
}
}
Expand Down

0 comments on commit cbeb08c

Please sign in to comment.