bestit / commercetools-odm
Makes the commercetools database accessible with the doctrine commons api.
Installs: 24 605
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 8
Open Issues: 4
Type:lib
Requires
- php: ^7.0
- ext-fileinfo: *
- ext-intl: *
- bestit/commercetools-async-pool: ^2 || ^3
- commercetools/commons: ^0.2
- commercetools/php-sdk: ^1.4 || ^2.6
- doctrine/common: ^2.6
- funct/funct: ^1.0
- psr/log: ^1.0@dev
Requires (Dev)
- best-it/php_codesniffer: ^1.2 || ^2.0
- phpunit/phpunit: ^5.5 || ^6.0
- 1.22.2
- 1.22.1
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.4
- 1.18.3
- 1.18.2
- 1.18.1
- 1.18.0
- 1.17.0
- 1.16.4
- 1.16.3
- 1.16.2
- 1.16.1
- 1.16.0
- 1.15.9
- 1.15.8
- 1.15.7
- 1.15.6
- 1.15.5
- 1.15.4
- 1.15.3
- 1.15.2
- 1.15.1
- 1.15.0
- 1.14.0
- 1.13.3
- 1.13.2
- 1.13.1
- 1.13.0
- 1.12.1
- 1.12.0
- 1.11.0
- 1.10.0
- 1.9.8
- 1.9.7
- 1.9.6
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.5
- 1.7.4
- 1.7.3
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- dev-master / 1.0.x-dev
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.56.0
- 0.55.3
- 0.55.2
- 0.55.1
- 0.55.0
- 0.54.4
- 0.54.3
- 0.54.2
- 0.54.1
- 0.54.0
- 0.53.2
- 0.53.1
- 0.53.0
- 0.52.1
- 0.52.0
- 0.51.0
- 0.50.3
- 0.50.2
- 0.50.1
- 0.50.0
- 0.49.1
- 0.49.0
- 0.48.0
- 0.47.1
- 0.47.0
- 0.46.4
- 0.46.3
- 0.46.2
- 0.46.1
- 0.46.0
- 0.45.1
- 0.45.0
- 0.44.0
- 0.43.3
- 0.43.2
- 0.43.1
- 0.43.0
- 0.42.0
- 0.41.0
- 0.40.0
- 0.39.0
- 0.38.0
- 0.37.1
- 0.37.0
- 0.36.0
- 0.35.0
- 0.34.1
- 0.34.0
- 0.33.0
- 0.32.0
- 0.31.1
- 0.31.0
- 0.30.2
- 0.30.1
- 0.30.0
- 0.29.4
- 0.29.3
- 0.29.2
- 0.29.1
- 0.29.0
- 0.28.0
- 0.27.0
- 0.26.1
- 0.26.0
- 0.25.3
- 0.25.2
- 0.25.1
- 0.25.0
- 0.24.9
- 0.24.8
- 0.24.7
- 0.24.6
- 0.24.5
- 0.24.4
- 0.24.3
- 0.24.2
- 0.24.1
- 0.24.0
- 0.23.1
- 0.23.0
- 0.22.0
- 0.21.4
- 0.21.3
- 0.21.2
- 0.21.1
- 0.21.0
- 0.20.1
- 0.20.0
- 0.19.1
- 0.19.0
- 0.18.1
- 0.18.0
- 0.17.0
- 0.16.6
- 0.16.5
- 0.16.4
- 0.16.3
- 0.16.2
- 0.16.1
- 0.16.0
- 0.15.0
- 0.14.0
- 0.13.1
- 0.13.0
- 0.12.2
- 0.12.1
- 0.12.0
- 0.11.1
- 0.11.0
- 0.10.2
- 0.10.1
- 0.10.0
- 0.9.0
- 0.8.17
- 0.8.16
- 0.8.15
- 0.8.14
- 0.8.13
- 0.8.12
- 0.8.11
- 0.8.10
- 0.8.9
- 0.8.8
- 0.8.7
- 0.8.6
- 0.8.5
- 0.8.4
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.1
- 0.7.0
- 0.6.1
- 0.6.0
- 0.5.1
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
- dev-feature/change-manager
- dev-feature/payment-action-builder
- dev-feature/support-order-states
- dev-feature/payments
- dev-feature/update-sdk
- dev-feature/refactor-add-variants
- dev-feature/fix-master-variant-handling
- dev-feature/fix-set-attribute
- dev-feature/variant-id-handling
- dev-feature/variant-sku
- dev-feature/refactor-variants
- dev-feature/DEN-3195-prices-variants
- dev-feature/DEN-2525-remove-attributes
- dev-feature/DEN-3162-description
- dev-feature/attribute-update-refactoring
- dev-feature/delete-variant-action
- dev-feature/remove-on-staged
- dev-feature/DEN-3163-order-change-actions
- dev-testing/retry-flush
- dev-feature/DEN-3120-tax-priority
- dev-feature/customer-company-name
- dev-feature/tax-category
- dev-feature/cart-tax-mode
- dev-bugfix/DEN-3034-fix-custom-line-item-action
- dev-feature/DEN-2597-customer-vat-id
- dev-feature/DEN-2525-refactor-price-handling
- dev-bugfix/lenum-enum
- dev-bugfix/missing-category-slug
- dev-feature/memory-cleanup
- dev-feature/DEN-1963-order-number
- dev-feature/DEN-1911-support-custom-field-references
- dev-feature/DEN-1521-fix-identical-enum-check
- dev-temp-fix
- dev-feature/DEN-285-order-attributes
- dev-bugfix/BICO-3838-shipping-method-cent-amount
- dev-feature/BICO-3458-add-line-item-with-custom
- dev-feature/shopping-lists
- dev-feature/remove-debug-in-uow
- dev-feature/DoctrineModels
This package is auto-updated.
Last update: 2024-11-17 21:30:48 UTC
README
Wraps the commercetools/php-sdk with the doctrine common api.
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:
$ composer require bestit/commercetools-odm
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
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.
You could use our bestit/commercetools-odm-bundle to kickstart your project.
Usage
A small example usage:
<?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 ...
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:
<?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.
Reset your cache, after changing the action builder setup.
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"