Skip to content
This repository has been archived by the owner on May 30, 2019. It is now read-only.

Commit

Permalink
Product page shows subcategories products
Browse files Browse the repository at this point in the history
  • Loading branch information
rogergros committed May 6, 2015
1 parent 9e7fd58 commit 98c716d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/Elcodi/Store/ProductBundle/Controller/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,18 @@ public function viewAction(CategoryInterface $category, $slug)
], 301);
}

$childrenCategories = $this
->get('elcodi.repository.category')
->getChildrenCategories($category);

$categories = array_merge(
[$category],
$childrenCategories->toArray()
);

$products = $this
->get('elcodi.repository.product')
->findBy([
'principalCategory' => $category,
'enabled' => true,
]);
->getAllFromCategories($categories);

return $this->renderTemplate(
'Pages:category-view.html.twig',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
{% block title %}{{ "template.store_template_bundle.category.view.category"|trans }}{{ category.name }}{% endblock title %}

{% block breadcrumb %}
{% if category.parent is not null %}
<li>
<a href="{{ url('store_category_products_list', { slug: category.parent.slug, id: category.parent.id }) }}">{{ category.parent.name }}</a> >
</li>
{% endif %}
<li>
<a href="{{ url('store_category_products_list', { slug: products.0.principalCategory.slug, id: products.0.principalCategory.id }) }}"><strong>{{ products.0.principalCategory }}</strong></a>
<a href="{{ url('store_category_products_list', { slug: category.slug, id: category.id }) }}"><strong>{{ category.name }}</strong></a>
</li>
{% endblock breadcrumb %}

Expand Down

0 comments on commit 98c716d

Please sign in to comment.