bestit / commercetools-customer-prices-bundle
Provides a commercetools substitute with custom objects to get customer individual prices.
Installs: 6 680
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Type:lib
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-10-29 04:25:43 UTC
README
There is no real support for individual customer prices in the the commercetools platform at this moment. You could try to add a lot of "channel prices" for your products, but you will hit some topics like a missing fallback in the search facets for the scopedPrice (no fallback to the normal price, if a channel price is missing), performance losses because of huge product data sets and maybe you hit rock bottom with the maximum document size of the database itself.
So you need a substitute. This bundle will provide you with a substitute based on custom objects like
{ "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" }
You can configure the field names for the container, price value, article and customer value!
API
You can inject/use the service best_it_ct_customer_prices.model.customer_price_collection to fetch your price with BestIt\CtCustomerPricesBundle\Model\CustomerPriceCollection::getByArticle(string $articleId). $articleId needs to match the data out of your custom object.
The lazy loaded service best_it_ct_customer_prices.model.customer_price_collection is "created" with a factory, which takes the authed User out of the [Security Token Storage](http://symfony .com/blog/new-in-symfony-2-6-security-component-improvements).
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require bestit/commercetools-customer-prices-bundle
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new BestIt\CtCustomerPricesBundle\BestItCtCustomerPricesBundle(), ); // ... } // ... }
Step 3: Configure the bundle
You can define a custom query for searching your custom objects. The following default query will be used
if you not set this field: container="{container}-{currencyValue}-{customerValue}"
You can use placeholders for your query:
# 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
Step 4: Mark your user object as usable.
Please implement the BestIt\CtCustomerPricesBundle\Model\CustomerInterface on your user object. The used id needs to match the customer data out of your custom object.
ToDos
- More Docs