bestit / commercetools-odm
使用 doctrine commons api 使 commercetools 数据库可访问。
1.22.2
2021-03-17 13:11 UTC
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-09-17 21:10:55 UTC
README
使用 doctrine common api 包装commercetools/php-sdk。
安装
步骤 1:下载
打开命令行,进入项目目录并执行以下命令以下载此扩展包的最新稳定版本
$ composer require bestit/commercetools-odm
此命令需要您全局安装了 Composer,具体请参考 Composer 文档的安装章节。
步骤 2:启用
odm 的核心脚本是基于 Doctrine\Common\Persistence\ObjectManager 的 BestIt\CommercetoolsODM\DocumentManager。只需填充其依赖项即可。
您可以使用我们的 bestit/commercetools-odm-bundle 来启动您的项目。
使用方法
一个小型使用示例
<?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();
贡献
关于如何为这个库贡献的一些建议...
元数据
这是这个库的主要问题:如何将 commercetools sdk 的结构映射到统一的 api。我们目前使用映射表来解决此问题。
<?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 ];
动作构建器
尽管我们采用面向对象的方式,但我们仍然支持 commercetools 的部分更新。请参考 BestIt\CommercetoolsODM\ActionBuilder\ActionBuilderInterface 接口以添加您自己的动作构建器。动作构建器创建与 changed property values 匹配的请求动作以发送到 commercetools。
在更改动作构建器设置后,请重新设置缓存。
进一步步骤
- 减少假设,例如,每个标准模型都有一个 id 和版本
- 移除对产品发布标记的硬连接,以发布预发布版本
- 添加每个动作构建器。目前并非所有内容都包含在内。
- 更多单元测试
- 更多文档
- 命名标准化:从 "documents" 移向 "objects"