bestit / commercetools-customer-prices-bundle
提供commercetools替代方案,使用自定义对象获取客户个体价格。
Requires
- php: ^7.0
- commercetools/php-sdk: ^1.4 || ^2.0
- symfony/cache: ^3.0
- symfony/dependency-injection: ^3.0
- symfony/proxy-manager-bridge: ^3.0
- symfony/security: ^3.0
- symfony/stopwatch: ^3.0
Requires (Dev)
Suggests
- ocramius/proxy-manager: Makes the price collection a lazy service.
This package is auto-updated.
Last update: 2024-08-29 04:03:41 UTC
README
目前,commercetools平台对个体客户价格没有实际支持。您可以尝试为您的产品添加大量的“渠道价格”,但您可能会遇到一些问题,例如在搜索功能中缺少scopedPrice的回退(如果没有渠道价格,则不会回退到正常价格),由于庞大的产品数据集导致的性能损失,以及可能触及数据库自身最大文档大小。
因此,您需要一个替代方案。此bundle将为您提供一个基于自定义对象(如)的替代方案:
{ "id": "UUID", "version": 1, "container": "YOUR-CONTAINER-NAME", "key": "KEY-1-2", "value": { "price": { "value": { "centAmount": 5000, "currencyCode": "EUR" }, "tiers": [ { "minimumQuantity": 10, "value": { "centAmount": 4000, "currencyCode": "EUR" } }, { "minimumQuantity": 20, "value": { "centAmount": 3000, "currencyCode": "EUR" } }, { "minimumQuantity": 30, "value": { "centAmount": 2000, "currencyCode": "EUR" } } ] }, "customer": "1", "article": "2", "currency": "EUR" }, "createdAt": "2017-08-04T06:51:44.642Z", "lastModifiedAt": "2017-08-14T00:04:08.763Z" }
您可以为容器、价格值、文章和客户值配置字段名称!
API
您可以使用服务 best_it_ct_customer_prices.model.customer_price_collection 来获取价格,使用 BestIt\CtCustomerPricesBundle\Model\CustomerPriceCollection::getByArticle(string $articleId)。$articleId需要与您的自定义对象中的数据匹配。
懒加载的服务 best_it_ct_customer_prices.model.customer_price_collection 使用工厂“创建”,该工厂从[安全令牌存储](http://symfony .com/blog/new-in-symfony-2-6-security-component-improvements)中获取授权用户。
安装
步骤1:下载Bundle
打开命令行,进入项目目录,并执行以下命令以下载此bundle的最新稳定版本:
$ composer require bestit/commercetools-customer-prices-bundle
此命令需要您已全局安装Composer,如Composer文档中的安装章节中所述。
步骤2:启用Bundle
然后,通过将其添加到项目app/AppKernel.php
文件中注册的bundle列表中启用bundle。
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new BestIt\CtCustomerPricesBundle\BestItCtCustomerPricesBundle(), ); // ... } // ... }
步骤3:配置bundle
您可以为搜索自定义对象定义一个自定义查询。如果您未设置此字段,则将使用以下默认查询:container="{container}-{currencyValue}-{customerValue}"
您可以在查询中使用占位符
# Default configuration for extension with alias: "best_it_ct_customer_prices" best_it_ct_customer_prices: # Please provide the service id for your cache adapter. cache_service_id: cache.app # Please provide the service id for your commercetools client. client_service_id: ~ # Required # Please provide the search query. You can use placeholder in your query query: 'container="customer-prices-{currencyValue}-{customerValue}"' # Please provide the name of the custom object container where the prices are saved. container: customer-prices fields: # Please provide the name of the custom object value field which saves the article id / number. article: article # Please provide the name of the custom object value field which saves the customer id / number. customer: customer # Please provide the name of the custom object value field which saves the currency. currency: currency # Please provide the name of the custom object value field which saves the price object. prices: prices
步骤4:标记用户对象为可用。
请实现在您的用户对象上BestIt\CtCustomerPricesBundle\Model\CustomerInterface。使用的id需要与您的自定义对象中的客户数据匹配。
待办事项
- 更多文档