2017 © Pedro Peláez
 

lib commercetools-odm

Makes the commercetools database accessible with the doctrine commons api.

image

bestit/commercetools-odm

Makes the commercetools database accessible with the doctrine commons api.

  • Wednesday, June 6, 2018
  • by WBLKonzept
  • Repository
  • 2 Watchers
  • 3 Stars
  • 7,669 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 7 Forks
  • 1 Open issues
  • 100 Versions
  • 7 % Grown

The README.md

bestit/commercetools-odm

Wraps the commercetools/php-sdk with the doctrine common api., (*1)

Installation

Step 1: Download

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*2)

$ composer require bestit/commercetools-odm

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)

Step 2: Enable

The central script of the odm is the BestIt\CommercetoolsODM\DocumentManager based on the Doctrine\Common\Persistence\ObjectManager. Just fill it with its dependencies and you are good to go., (*4)

You could use our bestit/commercetools-odm-bundle to kickstart your project., (*5)

Usage

A small example usage:, (*6)

<?php

// Load the product repository.
/** @var \BestIt\CommercetoolsODM\DocumentManagerInterface $documentManager */
/** @var \BestIt\CommercetoolsODM\Repository\ProductRepository $repository */
$repository = $documentManager->getRepository(\Commercetools\Core\Model\Product\Product::class);

// Fetch it from the database or create a new instance.
/** @var \Commercetools\Core\Model\Product\Product $product */
$product = $repository->findByKey($key) ??
    $documentManager->getClassMetadata(\Commercetools\Core\Model\Product\Product::class)->getNewInstance();

// Do your work.
if (!$product->getId()) {
    $product
        ->setProductType(\Commercetools\Core\Model\ProductType\ProductTypeReference::ofId('type'))
        // ....
}

// You get automatic but simple 409 conflict resolution if you use  this callback. If not, 409s lead to an exception. 
$documentManager->modify($product, function(\Commercetools\Core\Model\Product\Product $product) {
    $product->setKey('new-key');
});

// Persist the changes
$documentManager->persist($product);

// Detach it from the document manager (UnitOfWork) after flush.
$documentManager->detachDeferred($product);

// Flush the changes in the document manager to the repository.
$documentManager->flush();

Contribute

Some advices to contribute to this library ..., (*7)

Metadata

This is the main problem of this library: How to map the structure of the commercetools sdk to a unified api. We resolved it for the moment with a map:, (*8)

<?php
// ./src/Resources/config/metadata.php

use BestIt\CommercetoolsODM\Mapping\Annotations\RequestMap;

return [
    // Your model
    \Commercetools\Core\Model\Cart\Cart::class => [
        // The draft class for creating a new model
        'draft' => \Commercetools\Core\Model\Cart\CartDraft::class,
        // Which repo to use
        'repository' => \BestIt\CommercetoolsODM\Repository\CartRepository::class,
        // And the map for every needed request type.
        'requestClassMap' => (new RequestMap())
            ->setCreate(\Commercetools\Core\Request\Carts\CartCreateRequest::class)
            ->setDeleteById(\Commercetools\Core\Request\Carts\CartDeleteRequest::class)
            ->setFindById(\Commercetools\Core\Request\Carts\CartByIdGetRequest::class)
            ->setFindByCustomerId(\Commercetools\Core\Request\Carts\CartByCustomerIdGetRequest::class)
            ->setQuery(\Commercetools\Core\Request\Carts\CartQueryRequest::class)
            ->setUpdateById(\Commercetools\Core\Request\Carts\CartUpdateRequest::class)
    ],

    // ... map more models
];

Action Builder

Even if we work object oriented, we still support the partial updates of commercetools. Please consult the interface BestIt\CommercetoolsODM\ActionBuilder\ActionBuilderInterface to add your own action builder. The action builders create the request actions to commercetools matching the changed property values., (*9)

Reset your cache, after changing the action builder setup., (*10)

Further steps

  • Work with less assumptions, for example, every standard model has an id and version
  • Remove hard coupling to the publish marker on the product to publish the staged version
  • Add every action builder. Not every thing is there at the moment.
  • More unittesting
  • More documentation
  • Harmonize naming: Move away from "documents" to "objects"

The Versions

06/06 2018

dev-master

9999999-dev

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/06 2018
05/06 2018
06/04 2018
06/04 2018

dev-feature/add-supply-channel-to-add-line-item-action

dev-feature/add-supply-channel-to-add-line-item-action

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

07/03 2018
06/03 2018
06/03 2018
26/02 2018
06/02 2018
25/01 2018
24/01 2018
09/01 2018

dev-feature/shopping-lists

dev-feature/shopping-lists

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

25/12 2017
25/12 2017
24/12 2017
21/12 2017
21/12 2017

dev-bugfix/keep-non-changed-fields

dev-bugfix/keep-non-changed-fields

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

18/12 2017
17/12 2017
09/12 2017
05/12 2017
13/11 2017
27/10 2017
10/10 2017
09/10 2017
08/10 2017
04/10 2017
26/09 2017
19/09 2017
17/09 2017
08/09 2017
03/09 2017
31/08 2017
24/08 2017
20/08 2017
12/08 2017

0.30.2

0.30.2.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

04/08 2017

0.30.1

0.30.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

19/07 2017

0.30.0

0.30.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

18/07 2017

0.29.4

0.29.4.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/07 2017

0.29.3

0.29.3.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/07 2017

0.29.2

0.29.2.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/07 2017

0.29.1

0.29.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/07 2017

0.29.0

0.29.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/07 2017

0.28.0

0.28.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/07 2017

0.27.0

0.27.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2017

0.26.1

0.26.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2017

0.26.0

0.26.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/06 2017

0.25.3

0.25.3.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/06 2017

0.25.2

0.25.2.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/06 2017

0.25.1

0.25.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/06 2017

0.25.0

0.25.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

26/06 2017

0.24.9

0.24.9.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

26/06 2017

0.24.8

0.24.8.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

26/06 2017

0.24.7

0.24.7.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

26/06 2017

0.24.6

0.24.6.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

22/06 2017

0.24.5

0.24.5.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

21/06 2017

0.24.4

0.24.4.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

21/06 2017

0.24.3

0.24.3.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/06 2017

0.24.2

0.24.2.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

06/06 2017

0.24.1

0.24.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

01/06 2017

0.24.0

0.24.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

29/05 2017

0.23.1

0.23.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

25/05 2017

0.23.0

0.23.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

25/05 2017

0.22.0

0.22.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/05 2017

0.21.4

0.21.4.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/05 2017

0.21.3

0.21.3.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/05 2017

0.21.2

0.21.2.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/05 2017

0.21.1

0.21.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/05 2017

0.21.0

0.21.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

10/05 2017

0.20.1

0.20.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

10/05 2017

0.20.0

0.20.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

10/05 2017

0.19.1

0.19.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

09/05 2017

0.19.0

0.19.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

08/05 2017

0.18.1

0.18.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

08/05 2017

0.18.0

0.18.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/05 2017

0.17.0

0.17.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/05 2017

dev-feature/remove-debug-in-uow

dev-feature/remove-debug-in-uow

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

05/05 2017

0.16.6

0.16.6.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

18/04 2017

0.16.5

0.16.5.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

18/04 2017

0.16.4

0.16.4.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/04 2017

0.16.3

0.16.3.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

17/04 2017

0.16.2

0.16.2.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/04 2017

0.16.1

0.16.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/04 2017

0.16.0

0.16.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/04 2017

0.15.0

0.15.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/04 2017

0.14.0

0.14.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/04 2017

0.13.0

0.13.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

09/04 2017

0.12.2

0.12.2.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

09/04 2017

0.12.1

0.12.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

09/04 2017

0.12.0

0.12.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

06/04 2017

0.11.1

0.11.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

03/04 2017

0.11.0

0.11.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/03 2017

0.10.2

0.10.2.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/03 2017

0.10.1

0.10.1.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

23/03 2017

0.10.0

0.10.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

19/03 2017

0.9.0

0.9.0.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

13/03 2017

0.8.17

0.8.17.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

09/03 2017

0.8.16

0.8.16.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires

07/03 2017

0.8.14

0.8.14.0

Makes the commercetools database accessible with the doctrine commons api.

  Sources   Download

MIT

The Requires

 

The Development Requires