承接 bestit/commercetools-odm-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

bestit/commercetools-odm-bundle

Composer 安装命令:

composer require bestit/commercetools-odm-bundle

包简介

Makes the commercetools database accessible with the doctrine commons api.

README 文档

README

Makes the commercetools database accessible with the doctrine commons api. It still uses the commmercetools/php-sdk under the hood.

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-odm-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\CommercetoolsODMBundle\BestItCommercetoolsODMBundle(),
        );

        // ...
    }

    // ...
}

Step 3: Configure the Bundle

# Default configuration for "BestItCommercetoolsODMBundle"
bestit_commercetools_odm:

    # Please provide the service id for your commercetools client.
    client_service_id:    ~ # Required

    # Please provide the service id for your commercetools request async pool.
    pool_service_id:      ~

This bundle ships a client factory which you can use to create a client. Example:

services:
    Commercetools\Core\Client:
        factory: 'BestIt\CommercetoolsODMBundle\Factory\ClientFactory:create'
        arguments:
            - {client_id: '%env(COMMERCETOOLS_CLIENT_ID)%', client_secret: '%env(COMMERCETOOLS_CLIENT_SECRET)%', project: '%env(COMMERCETOOLS_PROJECT)%', scope: ['manage_project'] }
            - {locale: 'de', languages: ['de'] }

    BestIt\CommercetoolsODMBundle\Factory\ClientFactory:
        class: BestIt\CommercetoolsODMBundle\Factory\ClientFactory
        arguments: ['@cache.app', '@logger']

Usage

Event Listener with the sercice container

You can add an event listener to the typical live cycle events if you tag your service with the name best_it_commercetools_odm.event_listener. But don't forget the name of the event with the key event on your tag.

Example:

# app/config/services.yml
services:
    app.tokens.action_listener:
        class: AppBundle\EventListener\TokenListener
        arguments: ['%tokens%']
        tags:
            - { name: best_it_commercetools_odm.event_listener, event: postPersist }

the method of the service should match the event name.

Services

The service best_it.commercetools_odm.manager provices you with an extended Doctrine\Common\Persistence\ObjectManager.

the method of the service should match the event name.

Filters

You can add multiple filters to apply on requests. Just create one filter, implement the FilterInterface and tag the service with best_it_commercetools_odm.filter. The filter get the raw created request and will be applied just before the request will be send.

Example:

// ProductFilter.php
class ProductFilter implements FilterInterface
{
    /**
     * {@inheritdoc}
     */
    public function getKey()
    {
        return 'product';
    }

    /**
     * {@inheritdoc}
     */
    public function apply($request)
    {
        $request->setExpands(['masterVariant.attributes[*].value', 'productType', 'categories[*].ancestors[*]']);
        
        $request->channel('xyz');
        $request->currency('EUR');
    }
}
# app/config/services.yml
services:
    app.filter.product_filter:
        class: AppBundle\Filter\ProductFilter
        tags:
            - { name: best_it_commercetools_odm.filter }

Now you can apply the one or more filter whenever you want:

    app.repository.product_projection:
        class: BestIt\CommercetoolsODM\Model\ProductProjectionRepository
        factory: ["@best_it.commercetools_odm.manager", getRepository]
        arguments:
            - Commercetools\Core\Model\Product\ProductProjection
        calls:
            - [filter, ['projection', 'projection-categories']]

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-04-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固