setono / sylius-shop-the-look-plugin
为您的Sylius商店创建外观,让客户购买更多商品
v0.2.8
2022-04-08 12:52 UTC
Requires
- php: >=7.4
- doctrine/collections: ^1.6
- doctrine/orm: ^2.7
- knplabs/knp-menu: ^3.1
- sylius/resource-bundle: ^1.6
- symfony/config: ^4.4 || ^5.0
- symfony/dependency-injection: ^4.4 || ^5.0
- symfony/form: ^4.4 || ^5.0
- symfony/http-foundation: ^4.4 || ^5.0.7
- symfony/intl: ^4.4 || ^5.0
- symfony/options-resolver: ^4.4 || ^5.0
- symfony/templating: ^4.4 || ^5.0
- twig/twig: ^2.14
- webmozart/assert: ^1.9
Requires (Dev)
- friendsofphp/proxy-manager-lts: ^1.0
- fzaninotto/faker: ^1.9
- matthiasnoback/symfony-config-test: ^4.2
- matthiasnoback/symfony-dependency-injection-test: ^4.2
- phpspec/phpspec: ^7.1
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.16.1
- psalm/plugin-symfony: ^3.0
- roave/security-advisories: dev-latest
- setono/code-quality-pack: ^2.1.2
- sylius/sylius: ~1.7.11
- symfony/debug-bundle: ^5.1
- symfony/dotenv: ^5.3
- symfony/web-profiler-bundle: ^5.0
- symfony/web-server-bundle: ^4.4 || ^5.0
- symfony/webpack-encore-bundle: ^1.7
README
安装
使用Composer安装插件
composer require setono/sylius-shop-the-look-plugin
导入配置
# config/packages/setono_sylius_shop_the_look.yaml imports: - { resource: "@SetonoSyliusShopTheLookPlugin/Resources/config/app/config.yaml" }
(可选) 导入固定数据
如果您希望在开发过程中在应用程序中测试一些外观。
# config/packages/setono_sylius_shop_the_look.yaml imports: # ... - { resource: "@SetonoSyliusShopTheLookPlugin/Resources/config/app/fixtures.yaml" }
导入路由
# config/routes/setono_sylius_shop_the_look.yaml setono_sylius_shop_the_look: resource: "@SetonoSyliusShopTheLookPlugin/Resources/config/routes.yaml" # Or if your app doesn't use localized URLs: # resource: "@SetonoSyliusShopTheLookPlugin/Resources/config/routes_no_locale.yaml" # @see https://docs.sylius.com/en/latest/cookbook/shop/disabling-localised-urls.html
将插件类添加到您的 bundles.php
确保您在 SyliusGridBundle
之前添加它,否则您将收到异常。
<?php $bundles = [ // ... Setono\SyliusShopTheLookPlugin\SetonoSyliusShopTheLookPlugin::class => ['all' => true], Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], // ... ];
准备资源文件
如果您在您的应用程序中使用Webpack encore
- 将swiper添加到您的
package.json
yarn add swiper
- 在
webpack.config.js
中指定插件的脚本别名
// webpack.config.js // Admin const setonoShopTheLookPluginAdminResources = path.resolve(__dirname, 'vendor/setono/sylius-shop-the-look-plugin/src/Resources/private/admin/'); // ... adminConfig.resolve.alias['setono/shop-the-look-plugin'] = setonoShopTheLookPluginAdminResources; // ... // Shop const setonoShopTheLookPluginShopResources = path.resolve(__dirname, 'vendor/setono/sylius-shop-the-look-plugin/src/Resources/private/shop/'); // ... shopConfig.resolve.alias['setono/shop-the-look-plugin'] = setonoShopTheLookPluginShopResources;
- 使用插件的
apps/styles
// assets/admin/js/app.js import 'setono/shop-the-look-plugin/js/app';
// assets/shop/js/app.js import 'setono/shop-the-look-plugin/js/app'; import 'setono/shop-the-look-plugin/scss/app';
- 然后运行
yarn encore dev
重新构建它
如果您使用常规脚本包含
这不是默认支持的(slug生成脚本),但我猜您可以在应用程序的javascript文件中做类似这样的事情
(function ($) { 'use strict'; $.fn.extend({ // Put setono-shop-the-look-slug.js's content here }); $(document).ready(() => { $(document).lookSlugGenerator(); }); })(jQuery);
# config/packages/setono_sylius_shop_the_look.yaml imports: // ... - { resource: "@SetonoSyliusShopTheLookPlugin/Resources/config/app/ui/admin.yaml" }
此外,您还应该探索 src/Resources/private 并根据您的需求调整商店样式/脚本。
更新您的数据库
$ bin/console doctrine:migrations:diff $ bin/console doctrine:migrations:migrate
覆盖模板
从 src/Resources/views/templates/bundles 模板中注入外观折扣行到购物车/结账/订单模板,就像在 tests/Application/templates/bundles 中所做的那样。