fabit / sylius-odoo-product-plugin
Sylius应用的Odoo产品同步插件。
v1.0.0
2023-04-17 20:09 UTC
Requires
- php: ^7.4|^8.0|^8.1
- fabit/sylius-odoo-core-plugin: ^1.0
- lakion/mink-debug-extension: ^2.0
- sylius/sylius: ^1.10
- symfony/lock: ^4.0|^5.0
- symfony/messenger: ^4.0|^5.0
Requires (Dev)
- behat/behat: ^3.4
- behat/mink: ^1.7@dev
- behat/mink-browserkit-driver: ^1.3
- behat/mink-extension: ^2.2
- behat/mink-selenium2-driver: ^1.3
- friends-of-behat/page-object-extension: ^0.3
- friends-of-behat/suite-settings-extension: ^1.0
- friends-of-behat/symfony-extension: ^2.0
- friends-of-behat/variadic-extension: ^1.1
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^8.0
- sensiolabs/security-checker: ^5.0
- sylius-labs/coding-standard: ^4.3
- symfony/browser-kit: ^3.4|^4.3|^5.0
- symfony/debug-bundle: ^3.4|^4.3|^5.0
- symfony/dotenv: ^4.3|^5.0
- symfony/intl: ^3.4|^4.3|^5.0
- symfony/web-profiler-bundle: ^3.4|^4.3|^5.0
- symfony/web-server-bundle: ^3.4|^4.3|^5.0
- symplify/easy-coding-standard: ^10.1
This package is not auto-updated.
Last update: 2024-10-02 00:50:48 UTC
README
Fabit Odoo Product Plugin 骨架
此插件将Odoo产品同步到Sylius文档
有关Sylius插件开发的全面指南,请访问Sylius文档,在那里您可以找到插件开发指南,其中包含大量示例。
快速安装
- 创建新文件[项目]/]config/packages/sylius_odoo_product.yaml并将配置复制到其中
sylius_odoo_product: data_transform: product: mapping: - sylius_field: id odoo_field: id required: true default: '' allow_types: [int, 'null'] - sylius_field: productTmplId odoo_field: product_tmpl_id required: true default: '' allow_types: [int, 'null'] - sylius_field: code odoo_field: code required: true default: '' allow_types: [string, 'null'] - sylius_field: name odoo_field: name required: true default: '' allow_types: [string, 'null'] - sylius_field: description odoo_field: description required: true default: '' allow_types: [string, 'null'] - sylius_field: categId odoo_field: categ_id required: false default: [ ] allow_types: [array] - sylius_field: lst_price odoo_field: lst_price required: true default: '' allow_types: [float] - sylius_field: taxes_id odoo_field: taxes_id required: false default: [ ] allow_types: [array] - sylius_field: image1920 odoo_field: image_1920 required: true default: null allow_types: [string, boolean, 'null'] - sylius_field: active odoo_field: active required: true default: null allow_types: [string, boolean, 'null'] tax: mapping: - sylius_field: code odoo_field: id required: true default: '' allow_types: [string, 'null'] - sylius_field: name odoo_field: name required: true default: '' allow_types: [string, 'null'] - sylius_field: description odoo_field: description required: true default: '' allow_types: [string, 'null', 'bool'] - sylius_field: amount odoo_field: amount required: true default: '' allow_types: [float, 'null'] category: mapping: - sylius_field: code odoo_field: id required: true default: '' allow_types: [string, 'null'] - sylius_field: name odoo_field: name required: true default: '' allow_types: [string, 'null'] - sylius_field: parent odoo_field: parent_id required: true default: '' allow_types: [string, 'null']
-
运行composer以添加依赖项
composer require fabit/sylius-odoo-product-plugin
-
在
config/bundles.php
中添加以下条目Fabit\SyliusOdooProductPlugin\SyliusOdooProductPlugin::class => ['all' => true]
-
在
config/routes.yaml
中添加路由条目
fabit_sylius_odoo_product_plugin: resource: "@SyliusOdooProductPlugin/Resources/config/routing.yaml"
- 覆盖产品实体
src/Entity/Product/Product.php
,将ProductTrait添加到您的产品实体中
namespace App\Entity\Product; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\Product as BaseProduct; use Sylius\Component\Product\Model\ProductTranslationInterface; use Fabit\SyliusOdooProductPlugin\Traits\ProductTrait; /** * @ORM\Entity * @ORM\Table(name="sylius_product", indexes={ * @ORM\Index(name="sylius_odoo_product_plugin_odoo_product_tmpl_id", columns={"odoo_product_tmpl_id"}) * }) */ class Product extends BaseProduct { use ProductTrait;
- 覆盖产品变体实体
src/Entity/Product/ProductVariant.php
,将ProductVariantTrait添加到您的产品变体实体中
namespace App\Entity\Product; use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant; use Sylius\Component\Product\Model\ProductVariantTranslationInterface; use Fabit\SyliusOdooProductPlugin\Traits\ProductVariantTrait; /** * @ORM\Entity * @ORM\Table(name="sylius_product_variant", indexes={ * @ORM\Index(name="sylius_odoo_product_plugin_odoo_product_variant_id", columns={"odoo_product_variant_id"}) * }) */ class ProductVariant extends BaseProductVariant { use ProductVariantTrait;
-
在.env文件中添加以下变量
###> fabit/sylius-odoo-product-plugin ### odoo_url=https://demo.odoo.com odoo_db=odoo-datbase odoo_user=odoo-user odoo_password=odoo-password odoo_live_stock=True odoo_enable=1 ###> fabit/sylius-odoo-product-plugin ###
Sylius基本安装
-
运行以下命令安装Sylius
php bin/console sylius:install
- 注意:在演示Odoo中,使用
en_EN
作为本地化
- 注意:在演示Odoo中,使用
-
确保媒体目录具有写入权限
-
设置国家/地区和区域
INSERT INTO `sylius_country` (`id`, `code`, `enabled`) VALUES (NULL, 'FR', 1); INSERT INTO `sylius_zone` (`id`, `code`, `name`, `type`, `scope`) VALUES (NULL, 'FR', 'France', 'country', 'all'); INSERT INTO `sylius_zone_member` (`id`, `belongs_to`, `code`) VALUES (NULL, 1, 'FR');
执行Odoo命令
-
更新数据库表,运行命令更新数据库模式
php bin/console doctrine:schema:update --force
-
运行以下命令导入所有类别
php bin/console odoo:category:import
-
运行以下命令导入所有税费
php bin/console odoo:tax:import
-
运行以下命令导入所有税费
php bin/console odoo:product:import
Odoo同步后的Sylius
- 在配置 -> 通道中选择Odoo类别 "所有"
- 选择配送方式
- 选择支付方式
! 欣赏演示 !