setono / sylius-strands-plugin
集成Strands的插件
v1.0.0
2020-08-10 12:53 UTC
Requires
- php: ^7.3
- setono/tag-bag-bundle: ^2.0
- setono/tag-bag-twig: ^1.0
- sylius/sylius: ^1.4
Requires (Dev)
- matthiasnoback/symfony-config-test: ^4.2
- matthiasnoback/symfony-dependency-injection-test: ^4.1
- phpspec/phpspec: ^6.2
- phpunit/phpunit: ^9.2
- roave/security-advisories: dev-master
- setono/code-quality-pack: ^1.2
- setono/sylius-tag-bag-plugin: ^1.1
- symfony/debug-bundle: ^4.4 || ^5.1
- symfony/dotenv: ^4.4 || ^5.1
- symfony/intl: ^4.4 || ^5.1
- symfony/web-profiler-bundle: ^4.4 || ^5.1
This package is auto-updated.
Last update: 2024-09-15 10:29:13 UTC
README
将 Strands推荐引擎 集成到Sylius中。
安装
步骤 1: 下载插件
打开命令行,进入您的项目目录,然后执行以下命令以下载此插件的最新稳定版本
# Omit setono/sylius-tag-bag-plugin if you want to # override layout.html.twig as described at https://github.com/Setono/TagBagBundle#usage $ composer require setono/sylius-strands-plugin setono/sylius-tag-bag-plugin
此命令要求您全局安装Composer,请参阅Composer文档中的安装章节。
步骤 2: 启用插件
然后,将插件添加到项目中config/bundles.php
文件中注册的插件/包列表中,以启用插件
<?php # config/bundles.php return [ Setono\TagBagBundle\SetonoTagBagBundle::class => ['all' => true], // Use this bundle or override layout.html.twig as described at https://github.com/Setono/TagBagBundle#usage Setono\SyliusTagBagPlugin\SetonoSyliusTagBagPlugin::class => ['all' => true], Setono\SyliusStrandsPlugin\SetonoSyliusStrandsPlugin::class => ['all' => true], ];
步骤 3: 创建配置
# config/packages/setono_sylius_strands.yaml setono_sylius_strands: api_id: "%env(STRANDS_API_ID)%"
# .env
# Get it at https://retail.strands.com/account/info/
STRANDS_API_ID=YOUR_API_ID
用法
创建一个通用小部件
在您的twig模板中,您可以使用以下方式插入小部件
{{ strands_widget('template') }}
template
是您从这里获得的ID:strands.com/tpl/website。
它将输出以下内容:<div class="strandsRecs" tpl="template"></div>
创建购物车小部件
{{ strands_widget('template')|strands_add_cart_items }}
它将输出以下内容:<div class="strandsRecs" tpl="template" item="当前购物车中的商品列表"></div>
创建产品页面小部件
{{ strands_widget('template')|strands_add_item(product.code) }}
它将输出以下内容:<div class="strandsRecs" tpl="template" item="产品代码"></div>