-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OP-289: List bundles on product detail admin page
- Loading branch information
Showing
6 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
<services> | ||
<service id="bitbag_sylius_product_bundle.twig.extension.smash_promotion" class="BitBag\SyliusProductBundlePlugin\Twig\Extension\ProductBundleOrderItemExtension" public="false"> | ||
<argument type="service" id="bitbag_sylius_product_bundle.repository.product_bundle_order_item" /> | ||
<argument type="service" id="twig" /> | ||
<tag name="twig.extension" /> | ||
<service id="bitbag_sylius_product_bundle.twig.extension.smash_promotion" | ||
class="BitBag\SyliusProductBundlePlugin\Twig\Extension\ProductBundleOrderItemExtension" public="false"> | ||
<argument type="service" id="bitbag_sylius_product_bundle.repository.product_bundle_order_item"/> | ||
<argument type="service" id="twig"/> | ||
<tag name="twig.extension"/> | ||
</service> | ||
<service id="bitbag_sylius_product_bundle.twig.extension.product_bundles" | ||
class="BitBag\SyliusProductBundlePlugin\Twig\Extension\ProductBundlesExtension" public="false"> | ||
<argument type="service" id="bitbag_sylius_product_bundle.repository.product_bundle"/> | ||
<tag name="twig.extension"/> | ||
</service> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends '@SyliusAdmin/layout.html.twig' %} | ||
|
||
{% block title %}{{ 'sylius.ui.show_product'|trans }} | {{ product.name }}{% endblock %} | ||
|
||
{% block content %} | ||
{% if product.variants|length == 1 %} | ||
{% include "@SyliusAdmin/Product/Show/_simpleProduct.html.twig" %} | ||
{% else %} | ||
{% include "@SyliusAdmin/Product/Show/_configurableProduct.html.twig" %} | ||
{% endif %} | ||
|
||
{% set bundles = bitbag_get_bundles_containing_product(product) %} | ||
{% if bundles|length > 0 %} | ||
<div class="ui hidden divider"></div> | ||
<div> | ||
<h4 class="ui top attached large header">{{ 'bitbag_sylius_product_bundle.ui.bundles'|trans }}</h4> | ||
{% for bundle in bundles %} | ||
<div class="ui attached segment text-break"> | ||
<a href="{{ path('sylius_admin_product_update', {id: bundle.product.id}) }}"> | ||
{{ bundle.product.name }} | ||
</a> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusProductBundlePlugin\Twig\Extension; | ||
|
||
use BitBag\SyliusProductBundlePlugin\Entity\ProductBundleInterface; | ||
use BitBag\SyliusProductBundlePlugin\Entity\ProductInterface; | ||
use BitBag\SyliusProductBundlePlugin\Repository\ProductBundleRepositoryInterface; | ||
use Twig\Extension\AbstractExtension; | ||
use Twig\TwigFunction; | ||
|
||
final class ProductBundlesExtension extends AbstractExtension | ||
{ | ||
public function __construct( | ||
private ProductBundleRepositoryInterface $productBundleRepository, | ||
) { | ||
} | ||
|
||
public function getFunctions(): array | ||
{ | ||
return [ | ||
new TwigFunction('bitbag_get_bundles_containing_product', [$this, 'getBundlesForProduct'], ['is_safe' => ['html']]), | ||
]; | ||
} | ||
|
||
/** @return ProductBundleInterface[] */ | ||
public function getBundlesForProduct(ProductInterface $product): array | ||
{ | ||
return $this->productBundleRepository->findBundlesByVariants($product->getVariants()); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
tests/Application/templates/bundles/SyliusAdminBundle/Product/show.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{% include '@BitBagSyliusProductBundlePlugin/Admin/Product/show.html.twig' %} |