bestit / commercetools-cleanup
用于清理commercetools数据库的Shell应用程序。
1.2.0
2018-12-19 11:58 UTC
Requires
- php: ^7.0
- commercetools/php-sdk: ^1.7
- incenteev/composer-parameter-handler: ^2.0
- sensio/distribution-bundle: ^5.0
- sensio/framework-extra-bundle: ^3.0.2
- symfony/monolog-bundle: ^3.0.2
- symfony/polyfill-apcu: ^1.0
- symfony/symfony: ^3.2
Requires (Dev)
- phpunit/phpunit: ^5.5
- sensio/generator-bundle: ^3.0
- squizlabs/php_codesniffer: ^2.8
This package is auto-updated.
Last update: 2024-08-29 04:37:37 UTC
README
Shell应用程序,用于从您的commercetools数据库中删除配置中指定的谓词匹配的条目。
安装
步骤1:下载包
打开命令控制台,进入您的项目目录,并执行以下命令以下载此包的最新稳定版本
$ composer require bestit/commercetools-cleanup
此命令要求您全局安装Composer,具体请参阅Composer文档中的安装章节。
步骤2:启用包
然后,通过将其添加到项目app/AppKernel.php
文件中注册的包列表中,来启用该包。
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = []; // ... if (in_array($this->getEnvironment(), ['dev', 'test'], true)) { $bundles[] = new BestIt\CtCleanUpBundle\BestItCtCleanUpBundle(); } // ... } // ... }
步骤3:配置包
# Default configuration for "BestItCtCleanUpBundle" best_it_ct_clean_up: commercetools_client: # Required id: ~ # Required secret: ~ # Required project: ~ # Required scope: ~ # Required # Please provide the service id for your logging service. logger: ~ predicates: # Define your category predicates (https://dev.commercetools.com/http-api.html). category: [] # Define your customer predicates (https://dev.commercetools.com/http-api.html). customer: [] # Define your product predicates (https://dev.commercetools.com/http-api.html). product: []
示例
best_it_ct_clean_up: # Reuse your default credentials from the commercetools sdk commercetools_client: id: '%commercetools.client_id%' project: '%commercetools.project%' secret: '%commercetools.client_secret%' scope: '%commercetools.scope%' # Use your logger specially used for the cleanup logger: 'monolog.logger.%cleanup.log_channel%' predicates: # The predicates for customers which should be deleted. The array elements are combined to an or query. customer: - 'externalId is defined' - 'lastName="foobar" and email="test@example.com" product: # Delete every product which is not published and older than 5 minutes. - 'masterData(published=false) and lastModifiedAt <= "{{- 5 minutes}}"'
您可以使用包含在{{和}}之间的strtotime兼容字符串来获取动态日期检查。
步骤4:使用命令
$ php bin/console bestit:cleanup -s
如果您提供了-s/--simulate选项,则不会删除任何行,只会输出总计数。
进一步待办事项
- 更多单元测试
- 重构命令
- 添加更多类型
- 在删除过程中添加异常