定制 loevgaard/sylius-brand-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

loevgaard/sylius-brand-plugin

最新稳定版本:v3.0.0-alpha.3

Composer 安装命令:

composer require loevgaard/sylius-brand-plugin

包简介

A Sylius plugin for handling brands

README 文档

README

Latest Stable Version Total Downloads License build codecov

Add brand to your products in Sylius.

Requirements

  • PHP 8.2+
  • Sylius 2.0+
  • Symfony 6.4 or 7.4

Installation

Step 1: Download the plugin

composer require loevgaard/sylius-brand-plugin 

Step 2: Enable the plugin

Enable the plugin by adding it to the list of registered plugins/bundles in config/bundles.php file of your project before (!) SyliusGridBundle:

<?php # config/bundles.php return [ // ... Loevgaard\SyliusBrandPlugin\LoevgaardSyliusBrandPlugin::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], // ... ]; 

Step 3: Configure routing

# config/routes/loevgaard_sylius_brand.yaml loevgaard_sylius_brand: resource: "@LoevgaardSyliusBrandPlugin/config/routes.yaml" 

Step 4: Extend Product entity

Extend your Product entity to implement BrandAwareInterface:

<?php // src/Entity/Product/Product.php declare(strict_types=1); namespace App\Entity\Product; use Doctrine\ORM\Mapping as ORM; use Loevgaard\SyliusBrandPlugin\Model\BrandAwareInterface; use Loevgaard\SyliusBrandPlugin\Model\BrandAwareTrait; use Sylius\Component\Core\Model\Product as BaseProduct; #[ORM\Entity] #[ORM\Table(name: 'sylius_product')] class Product extends BaseProduct implements BrandAwareInterface { use BrandAwareTrait; } 

The BrandAwareTrait already includes the Doctrine ORM mapping attributes, so you don't need to add any additional mapping configuration.

Step 5: Configure Sylius resource

# config/packages/sylius_product.yaml sylius_product: resources: product: classes: model: App\Entity\Product\Product 

The above configuration is most likely already done in your application.

Step 6: Update your database schema

php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate 

Optional Configuration

Show Brand column in admin products list

# config/packages/loevgaard_sylius_brand.yaml imports: - { resource: "@LoevgaardSyliusBrandPlugin/config/grids/sylius_admin_product.yaml" } 

Fixtures

Include predefined brand fixtures to play with on your dev environment:

# config/packages/loevgaard_sylius_brand.yaml imports: - { resource: "@LoevgaardSyliusBrandPlugin/config/fixtures.yaml" } 

Or write your own:

# config/packages/my_fixtures.yaml sylius_fixtures: suites: my_brand_fixtures: fixtures: loevgaard_sylius_brand_plugin_brand: options: custom: my_brand: name: 'My brand' code: 'my-brand' images: - type: logo path: images/my-brand/logo.jpg products: - product_code_1 - product_code_2 

Load your fixtures:

php bin/console sylius:fixture:load my_brand_fixtures 

Development

Customization

Twig Hooks

The plugin uses Sylius Twig Hooks for customization. Available hook points:

Product form:

  • sylius_admin.product.create.content.form.sections.general (priority 250)
  • sylius_admin.product.update.content.form.sections.general (priority 250)

Brand form:

  • loevgaard_sylius_brand.brand.create.content
  • loevgaard_sylius_brand.brand.update.content
  • loevgaard_sylius_brand.brand.create.content.form.form_sections.general
  • loevgaard_sylius_brand.brand.update.content.form.form_sections.general
  • loevgaard_sylius_brand.brand.create.content.form.form_sections.media
  • loevgaard_sylius_brand.brand.update.content.form.form_sections.media

Translations

Currently supported languages:

  • English (en)
  • German (de)
  • French (fr)
  • Spanish (es)
  • Italian (it)
  • Dutch (nl)
  • Polish (pl)
  • Danish (da)
  • Swedish (sv)
  • Norwegian (no)
  • Finnish (fi)

统计信息

  • 总下载量: 151.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 29
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 29
  • Watchers: 3
  • Forks: 30
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固