valantic-spryker / customer-storage
允许将非隐私相关的客户数据发布到存储中。
Requires
- php: >=8.0
- spryker/customer: ^7.51
- spryker/customer-group: ^2.6
- spryker/event-behavior: ^1.25
- spryker/publisher-extension: ^1.0
- spryker/storage: ^3.21
- valantic-spryker/customer-group: ^1.0
Requires (Dev)
README
描述
- 允许将非隐私相关的客户数据发布到存储中。
安装
composer require valantic-spryker/customer-storage
- 注册发布插件
// Zed\Publisher\PublisherDependencyProvider.php /** * @return array */ private function getCustomerStoragePlugins(): array { return [ CustomerStorageConfig::PUBLISH_CUSTOMER => [ new CustomerWritePublisherPlugin(), new CustomerDeletePublisherPlugin(), new CustomerGroupToCustomerWritePublisherPlugin(), new CustomerGroupToCustomerDeletePublisherPlugin(), new CustomerAddressWritePublisherPlugin(), ], ]; }
- 创建客户存储队列
// Client\RabbitMq\RabbitMqConfig.php /** * @return array */ protected function getPublishQueueConfiguration(): array { return [ [...] CustomerStorageConfig::PUBLISH_CUSTOMER, [...] ]; } /** * @return array */ protected function getSynchronizationQueueConfiguration(): array { return [ [...] CustomerStorageConfig::SYNC_CUSTOMER_STORAGE, [...] ]; } /** * @return \ArrayObject */ protected function getQueueOptions(): ArrayObject { $queueOptionCollection = parent::getQueueOptions(); $queueOptionCollection->append($this->createQueueOptionTransfer(CustomerStorageConfig::SYNC_CUSTOMER_STORAGE, CustomerStorageConfig::SYNC_CUSTOMER_STORAGE_ERROR)); return $queueOptionCollection; }
- 将处理器添加到队列:worker命令
// Zed\Queue\QueueDependencyProvider.php /** * @param \Spryker\Zed\Kernel\Container $container * * @return array<\Spryker\Zed\Queue\Dependency\Plugin\QueueMessageProcessorPluginInterface> */ protected function getProcessorMessagePlugins(Container $container): array { [...] CustomerStorageConfig::PUBLISH_CUSTOMER => new EventQueueMessageProcessorPlugin(), CustomerStorageConfig::SYNC_CUSTOMER_STORAGE => new SynchronizationStorageQueueMessageProcessorPlugin(), [...] }
- 如果您使用默认的客户导入器,请确保触发customer-storage发布事件
// Zed\CustomerImport\Business\Model\CustomerImporterPlugin public function import(array $data): void { [...] QueueImporterPublisher::addEvent( CustomerStorageConfig::PUBLISH_CUSTOMER_WRITE, $idCustomer, ); [...] }
- 配置您想要公开的数据
// Zed\CustomerStorage\Business\Mapper\CustomerStorageMapper protected function getCustomerStorageData(SpyCustomerEntityTransfer $customerEntityTransfer): array { $data = []; $data['idCustomer'] = $customerEntityTransfer->getIdCustomer(); $data['customerGroup'] = ($customerEntityTransfer->getSpyCustomerGroupToCustomers()->count() > 0) ? ($customerEntityTransfer->getSpyCustomerGroupToCustomers()[0]->getCustomerGroup()?->getName()) : null; $data['sponsorReference'] = $customerEntityTransfer->getSponsorReference(); $data['priceGroup'] = $customerEntityTransfer->getPriceGroup(); $data['store'] = $customerEntityTransfer->getSpyStore()?->getName(); $data['country'] = $customerEntityTransfer->getBillingAddress()?->getCountry()?->getName(); $data['zipCode'] = $customerEntityTransfer->getBillingAddress()?->getZipCode(); return $data; }
- 如果您想使用
console publisher:trigger-events customer
-> 注册发布插件
// Zed\Publisher\PublisherDependencyProvider [...] new CustomerPublisherTriggerPlugin(), [...]
CLI 如何操作
PHP 容器: docker run -it --rm --name my-running-script -v "$PWD":/data spryker/php:latest bash
运行测试: codecept run --env standalone
修复器: vendor/bin/phpcbf --standard=phpcs.xml --report=full src/ValanticSpryker/
禁用opcache: mv /usr/local/etc/php/conf.d/docker-php-ext-opcache.ini /usr/local/etc/php/conf.d/docker-php-ext-opcache.iniold
XDEBUG
-
ip addr | grep '192.'
-
$docker-php-ext-enable xdebug
-
配置phpstorm(添加名为valantic的127.0.0.1 phpstorm服务器)
-
$PHP_IDE_CONFIG=serverName=valantic php -dxdebug.mode=debug -dxdebug.client_host=192.168.87.39 -dxdebug.start_with_request=yes ./vendor/bin/codecept run --env standalone
-
带有覆盖率的测试运行:
XDEBUG_MODE=coverage vendor/bin/codecept run --env standalone --coverage --coverage-xml --coverage-html
使用nodejs
- docker run -it --rm --name my-running-script -v "$PWD":/data node:18 bash