aquis/sylius-xporter-plugin

插件允许导出和导入 fixtures,格式为 yml。


README

安装

为了正确安装插件,请按照以下步骤进行

安装插件

开发阶段

,
    "repositories": [
        {
            "type": "path",
            "url": "../SyliusXporterPlugin"
        }
    ]

然后

composer require aquis/sylius-xporter-plugin:*@dev

修复 Sylius 相关错误

您可能会在 1.8 版本中遇到一个奇怪的错误:尝试从 bin/console 的命名空间加载类 "SecurityCheckerCommand",这可以通过可能从外部 docker 修复,因为内部会抛出允许的内存错误。

composer require sensiolabs/security-checker

然后修复缺失的目录

mkdir /srv/sylius/public/media/image

在 bundles.php 中启用插件,通过添加以下内容到末尾

...
Aquis\ProductDesignConfigurator\SyliusXporterPlugin::class => ['all' => true],

启用插件路由

将以下路由添加到您的项目 routes.yml 中

sylius-aquis-xporter-plugin.admin:
    # loads routes from the SyliusProductDesignConfigurator Plugin - Admin
    resource: '@SyliusXporterPlugin/Resources/config/admin_routing.yml'

sylius-aquis-xporter-plugin.shop:
    # loads routes from the SyliusProductDesignConfigurator Plugin - Shop
    resource: '@SyliusXporterPlugin/Resources/config/shop_routing.yml'

在您的项目 _sylius.yml 中导入配置

- { resource: "@SyliusXporterPlugin/Resources/config/packages/_sylius.yml" }
- { resource: "@SyliusXporterPlugin/Resources/config/packages/oneup_flysystem.yml" }
- { resource: "@SyliusXporterPlugin/Resources/config/packages/monolog.yml" }

在项目实体中添加所需的特性

+++ b/src/Entity/Channel/Channel.php
+use Aquis\XporterPlugin\Model\Channel\ChannelTrait;
+    use ChannelTrait;

+++ b/src/Entity/Customer/Customer.php
+use Aquis\XporterPlugin\Model\Customer\CustomerTrait;
+    use CustomerTrait;

+++ b/src/Entity/Order/Adjustment.php
+use Aquis\XporterPlugin\Model\Order\AdjustmentTrait;
+    use AdjustmentTrait;

+++ b/src/Entity/Order/OrderItem.php
+use Aquis\XporterPlugin\Model\Order\OrderItemTrait;
+    use OrderItemTrait;

+++ b/src/Entity/Payment/PaymentMethod.php
+use Aquis\XporterPlugin\Model\Payment\PaymentMethodTrait;
+    use PaymentMethodTrait;

+++ b/src/Entity/Product/Product.php
+use Aquis\XporterPlugin\Model\Product\ProductTrait as ProductTrait_EX;
+    use ProductTrait_EX;
 
+++ b/src/Entity/Product/ProductAttributeValue.php
+use Aquis\XporterPlugin\Model\Product\ProductAttributeValueTrait;
+    use ProductAttributeValueTrait;

+++ b/src/Entity/Product/ProductVariant.php
+use Aquis\XporterPlugin\Model\Product\ProductVariantTrait as ProductVariantTrait_EX;
+    use ProductVariantTrait_EX;
 
+++ b/src/Entity/Promotion/Promotion.php
+use Aquis\XporterPlugin\Model\Promotion\PromotionTrait;
+    use PromotionTrait;

+++ b/src/Entity/Shipping/ShippingMethod.php
+use Aquis\XporterPlugin\Model\Shipping\ShippingMethodTrait;
+    use ShippingMethodTrait;

+++ b/src/Entity/Taxation/TaxRate.php
+use Aquis\XporterPlugin\Model\Taxation\TaxRateTrait;
+    use TaxRateTrait;

+++ b/src/Entity/Taxonomy/Taxon.php
+use Aquis\XporterPlugin\Model\Taxonomy\TaxonTrait;
+    use TaxonTrait;

+++ b/src/Entity/User/ShopUser.php
+use Aquis\XporterPlugin\Model\User\ShopUserTrait;
+    use ShopUserTrait;

+++ b/src/Entity/Channel/Channel.php
+use Aquis\XporterPlugin\Model\Channel\ChannelTrait;
+    use ChannelTrait;

+++ b/src/Entity/Customer/Customer.php
+use Aquis\XporterPlugin\Model\Customer\CustomerTrait;
+    use CustomerTrait;

+++ b/src/Entity/Order/Adjustment.php
+use Aquis\XporterPlugin\Model\Order\AdjustmentTrait;
+    use AdjustmentTrait;

+++ b/src/Entity/Order/OrderItem.php
+use Aquis\XporterPlugin\Model\Order\OrderItemTrait;
+    use OrderItemTrait;

+++ b/src/Entity/Payment/PaymentMethod.php
+use Aquis\XporterPlugin\Model\Payment\PaymentMethodTrait;
+    use PaymentMethodTrait;

+++ b/src/Entity/Product/Product.php
+use Aquis\XporterPlugin\Model\Product\ProductTrait as ProductTrait_EX;
+    use ProductTrait_EX;
 
+++ b/src/Entity/Product/ProductAttributeValue.php
+use Aquis\XporterPlugin\Model\Product\ProductAttributeValueTrait;
+    use ProductAttributeValueTrait;

+++ b/src/Entity/Product/ProductVariant.php
+use Aquis\XporterPlugin\Model\Product\ProductVariantTrait as ProductVariantTrait_EX;
+    use ProductVariantTrait_EX;
 
+++ b/src/Entity/Promotion/Promotion.php
+use Aquis\XporterPlugin\Model\Promotion\PromotionTrait;
+    use PromotionTrait;

+++ b/src/Entity/Shipping/ShippingMethod.php
+use Aquis\XporterPlugin\Model\Shipping\ShippingMethodTrait;
+    use ShippingMethodTrait;

+++ b/src/Entity/Taxation/TaxRate.php
+use Aquis\XporterPlugin\Model\Taxation\TaxRateTrait;
+    use TaxRateTrait;

+++ b/src/Entity/Taxonomy/Taxon.php
+use Aquis\XporterPlugin\Model\Taxonomy\TaxonTrait;
+    use TaxonTrait;

+++ b/src/Entity/User/ShopUser.php
+use Aquis\XporterPlugin\Model\User\ShopUserTrait;
+    use ShopUserTrait;

运行以下命令以导出您的数据

数据可以从任何实体开始,所有相关信息将被导入到 yaml 文件中

bin/console  aquis:fixture:dump App\\Entity\\Product\\Product --ids=1,3 --debug=true

测试插件

我们使用 Behat、PHPSpec 和 PHPUnit 来测试此插件。

如何运行测试

从插件根目录,运行以下命令

$ (cd tests/Application && yarn install)
$ (cd tests/Application && yarn build)
$ (cd tests/Application && bin/console assets:install public -e test)

$ (cd tests/Application && bin/console doctrine:database:create -e test)
$ (cd tests/Application && bin/console doctrine:schema:create -e test)

要设置插件数据库,请记住在 tests/Application/.envtests/Application/.env.test 中配置您的数据库凭证。

使用方法

运行插件测试

  • PHPUnit

    $ bin/phpunit
  • PHPSpec

    $ bin/phpspec run
  • Behat

    $ bin/behat

使用此插件打开 Sylius

  • 使用 test 环境

    $ (cd tests/Application && bin/console sylius:fixtures:load -e test)
    $ (cd tests/Application && bin/console server:run -d public -e test)
  • 使用 dev 环境

    $ (cd tests/Application && bin/console sylius:fixtures:load -e dev)
    $ (cd tests/Application && bin/console server:run -d public -e dev)

完成...

Sylius & API-PLATFORM
https://docs.sylius.com/en/latest/api/unified_api/introduction.html
获取服务名称

bin/console debug:container | grep state_machine | grep -vE 'Transition|Definition' | awk '{ print $1 }'

刷新 js 和 css

bin/console assets:install web --ansi

bin/console debug:container sylius.repository.product

安装开发版本

COMPOSER=composer.dev.json composer install

如果此插件对您有帮助,请为我买一杯啤酒

alt text

https://www.paypal.com/donate?hosted_button_id=KNKTPJXM8PEEQ