asdoria/sylius-facet-filter-plugin
Composer 安装命令:
composer require asdoria/sylius-facet-filter-plugin
包简介
A Simply Facet filter plugin for Sylius
README 文档
README
Asdoria Facet Filter Bundle
This plugin allows to to link facets to specific resources in your Sylius Shop
Sylius offers a system of products' attribute, options and some more. However, there's no native way to only use them on product from specific taxons(categories). This may be a problem when/if you wish to let the user filter your catalog by using these facets. Our plugin allows you to link specific attributes, options and other facets to specific taxons. This way, you can easily decide which filters to display and where
Features
- Create groups of facets
- Create customizable facet filters tied to specific products' characteristics
- Easily create facet collections
- Attach the facet filters to your taxons or other resources
Installation
-
run
composer require asdoria/sylius-facet-filter-plugin -
Add the bundle in
config/bundles.php. You must put it ABOVESyliusGridBundle
Asdoria\SyliusFacetFilterPlugin\AsdoriaSyliusFacetFilterPlugin::class => ['all' => true], [...] Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
- Import routes in
config/routes.yaml
asdoria_facet_filter: resource: "@AsdoriaSyliusFacetFilterPlugin/Resources/config/routing.yaml" prefix: /admin
- add the facets_filters filter into you grid config exemple for in
config/packages/grids/sylius_shop_product.yamlbut is already configure into the bundle for this grid
sylius_grid: grids: sylius_shop_product: filters: facets_filters: type: facets_filters label: false options: owner: taxon # filterBy: owner | funnel # this option "filterBy" is optional but if you specify funnel, the different filters will be filled with the rest of the filtered products. # this option "filterBy" is optional but if you specify owner, the different filters will be filled with the list of attributes of the category. # This option "filterBy" is optional but if you don't specify it, the different filters will be filled with the list of attributes of all shops.
- Import the plugin's config and add new config for
sylius.shop.product.index.searchevent inconfig/packages/_sylius.yaml
imports: - { resource: "@AsdoriaSyliusFacetFilterPlugin/Resources/config/config.yaml"} ... sylius_ui: events: sylius.shop.product.index.search: blocks: search: template: "@SyliusUi/Block/_legacySonataEvent.html.twig" priority: 30 context: event: sylius.shop.product.index.disabled_search
- Implement the Facet Interface and Trait in your Taxon Entity
App/Entity/Taxonomy/Taxon.php.
// ... use Asdoria\SyliusFacetFilterPlugin\Model\Aware\FacetFilterCodeAwareInterface; use Asdoria\SyliusFacetFilterPlugin\Traits\FacetFilterCodeTrait; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\Taxon as BaseTaxon; use Sylius\Component\Taxonomy\Model\TaxonTranslationInterface; /** * @ORM\Entity * @ORM\Table(name="sylius_taxon") */ class Taxon extends BaseTaxon implements FacetFilterCodeAwareInterface { use FacetFilterCodeTrait; protected function createTranslation(): TaxonTranslationInterface { return new TaxonTranslation(); } }
- Override or create if not already existing the Taxon Form template in
templates/bundles/SyliusAdminBundle/Taxon/_form.html.twig.
{% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationFormWithSlug %}
<div class="ui segment">
{{ form_errors(form) }}
<div class="three fields">
{{ form_row(form.code) }}
{{ form_row(form.parent) }}
{{ form_row(form.facetFilterCode) }}
</div>
<div class="fields">
{{ form_row(form.enabled) }}
</div>
</div>
{{ translationFormWithSlug(form.translations, '@SyliusAdmin/Taxon/_slugField.html.twig', taxon) }}
{% include '@SyliusAdmin/Taxon/_media.html.twig' %}
- Override or create if not already existing the Product Index template in
templates/bundles/SyliusShopBundle/Product/index.html.twig
{% extends '@SyliusShop/layout.html.twig' %}
{% block content %}
{% include '@SyliusShop/Product/Index/_header.html.twig' %}
<div class="ui stackable grid">
<div class="four wide column">
{% include '@SyliusShop/Product/Index/_sidebar.html.twig' %}
<div class="ui fluid vertical menu"></div>
<div class="ui fluid vertical menu"></div>
{% include '@SyliusShop/Product/Index/_search.html.twig' %}
</div>
<div class="twelve wide column">
{% include '@SyliusShop/Product/Index/_main.html.twig' %}
</div>
</div>
{% endblock %}
-
run
php bin/console do:mi:mito update the database schema -
Finally, add translations to
config/packages/translation.yaml:
framework:
default_locale: '%locale%'
translator:
paths:
- '%kernel.project_dir%/translations'
fallbacks:
- '%locale%'
- 'en'
Demo
You can see the result for the user here with caps: here.
If you want to try to create filters, go on the admin authentication page and connect with:
Login: asdoria
Password: asdoria
Then go on facet filters page in back office.
Note that we have developed several other open source plugins for Sylius, whose demos and documentation are listed on the following page.
Usage
-
In the back office, inside the
Configurationsection, go toFacet Filters. -
Click on
Edit GroupsandCreatebuttons and create a new one. Fill the fields with a code that will identify your facet group. Of course, this will not be the name on the user side: you can specify a name in each language below in the form. Groups will help you organize your filters and group them when displaying on your site. -
Once back on the previous page, click on
Configure childrenlinked to your new facet group. Fill the form in the same way as previously. -
Return to the
Facet Filterpage, and clickCreateto initialize Filters targetting a specific Taxon. Inside the Code input, enter the code of a taxon you wish to create a filter for. This code can be found in the taxon's edit page at{your-domain}/admin/taxons/{id}/editunder Slug. -
The interesting part begin here. Go on
Facet Filterspage, and click onEdit facetsassociated to your new filter. Several choices are available, let selectCreate an attribute facet.
You can now fill the form with some cool things such as:
- attribute to filter
- segment, which represent the filter's group. Obviously, you can change the facet's name for each language to adapt your content by country.
- Go on the "Taxons" admin page and click on the three grey dots next to each other linked to the category of products you want to filter. Then, click on "Edit" button.
You can choose the facet filter to be used on your products.
- Finally, see the results on the user side of your shop!
asdoria/sylius-facet-filter-plugin 适用场景与选型建议
asdoria/sylius-facet-filter-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7.64k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2022 年 06 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「sylius」 「sylius-plugin」 「monofony」 「asdoria」 「facet filter」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 asdoria/sylius-facet-filter-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 asdoria/sylius-facet-filter-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 asdoria/sylius-facet-filter-plugin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Implementation of the Omnibus Directive for Sylius application.
Bulk export of sylius resources
Sylius plugin that integrates Addwish
Setono example plugin for Sylius.
Will translate fragments of text automatically
Use price tiers in your Sylius store.
统计信息
- 总下载量: 7.64k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 12
- 点击次数: 8
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-02





