定制 valantic-spryker/customer-storage 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

valantic-spryker/customer-storage

Composer 安装命令:

composer require valantic-spryker/customer-storage

包简介

Allows to publish non privacy related customer data into storage.

关键字:

README 文档

README

Minimum PHP Version

Description

  • Allows to publish non privacy related customer data into storage.

Install

  • composer require valantic-spryker/customer-storage
  • register publisher plugins
    // Zed\Publisher\PublisherDependencyProvider.php
    /**
     * @return array
     */
    private function getCustomerStoragePlugins(): array
    {
        return [
            CustomerStorageConfig::PUBLISH_CUSTOMER => [
                new CustomerWritePublisherPlugin(),
                new CustomerDeletePublisherPlugin(),
                new CustomerGroupToCustomerWritePublisherPlugin(),
                new CustomerGroupToCustomerDeletePublisherPlugin(),
                new CustomerAddressWritePublisherPlugin(),
            ],
        ];
    }
  • create customer storage queues
 // 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;
    }
  • add processor to queue:worker command
    // 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(),
        [...]
    }
    
  • if you use default customer importer, ensure customer-storage publisher event is triggered
    // Zed\CustomerImport\Business\Model\CustomerImporterPlugin
    public function import(array $data): void
    {
        [...]
            QueueImporterPublisher::addEvent(
                CustomerStorageConfig::PUBLISH_CUSTOMER_WRITE,
                $idCustomer,
            );
        [...]
    }
            
  • configure the data you like to expose
    // 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;
    }
  • if you like to use console publisher:trigger-events customer -> register publisher plugin
    // Zed\Publisher\PublisherDependencyProvider
    [...]
    new CustomerPublisherTriggerPlugin(),
    [...]

HowTos Cli

PHP Container: docker run -it --rm --name my-running-script -v "$PWD":/data spryker/php:latest bash

Run Tests: codecept run --env standalone

Fixer: vendor/bin/phpcbf --standard=phpcs.xml --report=full src/ValanticSpryker/

Disable 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

  • configure phpstorm (add 127.0.0.1 phpstorm server with name valantic)

  • $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

  • Run Tests with coverage: XDEBUG_MODE=coverage vendor/bin/codecept run --env standalone --coverage --coverage-xml --coverage-html

use nodejs

  • docker run -it --rm --name my-running-script -v "$PWD":/data node:18 bash

统计信息

  • 总下载量: 14.78k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 5
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2023-08-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固