diff --git a/src/Resources/views/Shop/Page/show.html.twig b/src/Resources/views/Shop/Page/show.html.twig
index d36002715..a62f89963 100755
--- a/src/Resources/views/Shop/Page/show.html.twig
+++ b/src/Resources/views/Shop/Page/show.html.twig
@@ -42,8 +42,8 @@
{{ bitbag_cms_render_content(page) }}
-
- {% include '@BitBagSyliusCmsPlugin/Shop/Page/Show/_sections.html.twig' %}
+
+ {% include '@BitBagSyliusCmsPlugin/Shop/Page/Show/_collections.html.twig' %}
{% if page.products|length > 0 %}
diff --git a/src/Resources/views/Shop/Product/_pagesBySection.html.twig b/src/Resources/views/Shop/Product/_pagesByCollection.html.twig
similarity index 96%
rename from src/Resources/views/Shop/Product/_pagesBySection.html.twig
rename to src/Resources/views/Shop/Product/_pagesByCollection.html.twig
index 8a695a5bd..a8e01f3bc 100644
--- a/src/Resources/views/Shop/Product/_pagesBySection.html.twig
+++ b/src/Resources/views/Shop/Product/_pagesByCollection.html.twig
@@ -1,6 +1,6 @@
{% for column in data %}
- {{ column.section.name }}
+ {{ column.collection.name }}
diff --git a/src/Sorter/CollectionsSorter.php b/src/Sorter/CollectionsSorter.php
new file mode 100644
index 000000000..7e03e77ad
--- /dev/null
+++ b/src/Sorter/CollectionsSorter.php
@@ -0,0 +1,46 @@
+updateCollectionsArray($page, $result);
+ }
+
+ return $result;
+ }
+
+ private function updateCollectionsArray(PageInterface $page, array $currentResult): array
+ {
+ Assert::isIterable($page->getCollections());
+ foreach ($page->getCollections() as $collection) {
+ $collectionCode = $collection->getCode();
+ Assert::notNull($collectionCode);
+ if (!array_key_exists($collectionCode, $currentResult)) {
+ $currentResult[$collectionCode] = [];
+ $currentResult[$collectionCode]['collection'] = $collection;
+ }
+
+ $currentResult[$collectionCode][] = $page;
+ }
+
+ return $currentResult;
+ }
+}
diff --git a/src/Sorter/SectionsSorterInterface.php b/src/Sorter/CollectionsSorterInterface.php
similarity index 79%
rename from src/Sorter/SectionsSorterInterface.php
rename to src/Sorter/CollectionsSorterInterface.php
index 156e9ab58..1bfd479b6 100644
--- a/src/Sorter/SectionsSorterInterface.php
+++ b/src/Sorter/CollectionsSorterInterface.php
@@ -10,7 +10,7 @@
namespace BitBag\SyliusCmsPlugin\Sorter;
-interface SectionsSorterInterface
+interface CollectionsSorterInterface
{
- public function sortBySections(array $pages): array;
+ public function sortByCollections(array $pages): array;
}
diff --git a/src/Sorter/SectionsSorter.php b/src/Sorter/SectionsSorter.php
deleted file mode 100644
index 4f32b3e9f..000000000
--- a/src/Sorter/SectionsSorter.php
+++ /dev/null
@@ -1,46 +0,0 @@
-updateSectionsArray($page, $result);
- }
-
- return $result;
- }
-
- private function updateSectionsArray(PageInterface $page, array $currentResult): array
- {
- Assert::isIterable($page->getSections());
- foreach ($page->getSections() as $section) {
- $sectionCode = $section->getCode();
- Assert::notNull($sectionCode);
- if (!array_key_exists($sectionCode, $currentResult)) {
- $currentResult[$sectionCode] = [];
- $currentResult[$sectionCode]['section'] = $section;
- }
-
- $currentResult[$sectionCode][] = $page;
- }
-
- return $currentResult;
- }
-}
diff --git a/src/Twig/Runtime/RenderProductPagesRuntime.php b/src/Twig/Runtime/RenderProductPagesRuntime.php
index ad8f0cdf7..f930ee963 100644
--- a/src/Twig/Runtime/RenderProductPagesRuntime.php
+++ b/src/Twig/Runtime/RenderProductPagesRuntime.php
@@ -11,7 +11,7 @@
namespace BitBag\SyliusCmsPlugin\Twig\Runtime;
use BitBag\SyliusCmsPlugin\Repository\PageRepositoryInterface;
-use BitBag\SyliusCmsPlugin\Sorter\SectionsSorterInterface;
+use BitBag\SyliusCmsPlugin\Sorter\CollectionsSorterInterface;
use Sylius\Component\Channel\Context\ChannelContextInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Twig\Environment;
@@ -23,23 +23,23 @@ public function __construct(
private PageRepositoryInterface $pageRepository,
private ChannelContextInterface $channelContext,
private Environment $templatingEngine,
- private SectionsSorterInterface $sectionsSorter,
+ private CollectionsSorterInterface $collectionsSorter,
) {
}
- public function renderProductPages(ProductInterface $product, string $sectionCode = null): string
+ public function renderProductPages(ProductInterface $product, string $collectionCode = null): string
{
$channelCode = $this->channelContext->getChannel()->getCode();
Assert::notNull($channelCode, 'Channel code for channel is null');
- if (null !== $sectionCode) {
- $pages = $this->pageRepository->findByProductAndSectionCode($product, $sectionCode, $channelCode, null);
+ if (null !== $collectionCode) {
+ $pages = $this->pageRepository->findByProductAndCollectionCode($product, $collectionCode, $channelCode, null);
} else {
$pages = $this->pageRepository->findByProduct($product, $channelCode, null);
}
- $data = $this->sectionsSorter->sortBySections($pages);
+ $data = $this->collectionsSorter->sortByCollections($pages);
- return $this->templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesBySection.html.twig', [
+ return $this->templatingEngine->render('@BitBagSyliusCmsPlugin/Shop/Product/_pagesByCollection.html.twig', [
'data' => $data,
]);
}
diff --git a/src/Twig/Runtime/RenderProductPagesRuntimeInterface.php b/src/Twig/Runtime/RenderProductPagesRuntimeInterface.php
index 65bc49130..b8cb4be4b 100644
--- a/src/Twig/Runtime/RenderProductPagesRuntimeInterface.php
+++ b/src/Twig/Runtime/RenderProductPagesRuntimeInterface.php
@@ -15,5 +15,5 @@
interface RenderProductPagesRuntimeInterface extends RuntimeExtensionInterface
{
- public function renderProductPages(ProductInterface $product, string $sectionCode = null): string;
+ public function renderProductPages(ProductInterface $product, string $collectionCode = null): string;
}
diff --git a/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml b/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml
index 12b0a714b..e3f397167 100644
--- a/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml
+++ b/tests/Application/config/packages/bitbag_sylius_cms_plugin.yaml
@@ -11,7 +11,7 @@ sylius_fixtures:
orm_purger: ~
logger: ~
fixtures:
- section:
+ collection:
options:
custom:
blog:
@@ -46,20 +46,20 @@ sylius_fixtures:
Click one of the below products to see what you can do with the blocks in your product view!
- section_info_block:
+ collection_info_block:
channels:
- "FASHION_WEB"
- sections:
+ collections:
- "products"
translations:
en_US:
content: |
- The block you can see on the left is just a block associated with a section named Products
+ The block you can see on the left is just a block associated with a collection named Products
With this feature, you can render any block you want on the product page, like size table, delivery information, or even promotion banner.
It's done with a simple controller render:
-
{{ render(path('bitbag_sylius_cms_plugin_shop_block_index_by_section_code', {'sectionCode' : 'products', 'template' : '@BitBagSyliusCmsPlugin/Shop/Block/index.html.twig'})) }}
+
{{ render(path('bitbag_sylius_cms_plugin_shop_block_index_by_collection_code', {'collectionCode' : 'products', 'template' : '@BitBagSyliusCmsPlugin/Shop/Block/index.html.twig'})) }}
product_info_block:
channels:
- "FASHION_WEB"
@@ -99,7 +99,7 @@ sylius_fixtures:
lorem_ipsum:
channels:
- "FASHION_WEB"
- sections:
+ collections:
- "homepage"
translations:
en_US:
@@ -191,7 +191,7 @@ sylius_fixtures:
type: image
path: "%fixtures_dir%/sale.jpeg"
original_name: "sale.jpeg"
- sections:
+ collections:
- "products"
media_with_products:
type: image
@@ -221,7 +221,7 @@ sylius_fixtures:
- "FASHION_WEB"
number: 14
products: 5
- sections:
+ collections:
- "blog"
translations:
en_US:
@@ -248,7 +248,7 @@ sylius_fixtures:
products: 5
channels:
- "FASHION_WEB"
- sections:
+ collections:
- "general"
- "store"
translations:
diff --git a/tests/Application/templates/bundles/SyliusShopBundle/Product/show.html.twig b/tests/Application/templates/bundles/SyliusShopBundle/Product/show.html.twig
index 050512ac4..ca16f8453 100755
--- a/tests/Application/templates/bundles/SyliusShopBundle/Product/show.html.twig
+++ b/tests/Application/templates/bundles/SyliusShopBundle/Product/show.html.twig
@@ -50,7 +50,7 @@