php-etl/flow-akeneo

此包已被废弃且不再维护。作者建议使用php-etl/akeneo-plugin包代替。

Akeneo API客户端的适配器

安装: 0

依赖: 0

建议者: 0

安全性: 0

星标: 4

关注者: 3

分支: 1

开放问题: 4

类型:gyroscops-plugin


README

Quality (PHPStan lvl 4) PHPUnit Infection PHPStan level 5 PHPStan level 6 PHPStan level 7 PHPStan level 8 PHP

目标

此包旨在将Akeneo PHP客户端集成到Pipeline堆栈中。此集成与Akeneo客户端兼容。

原则

此库中的工具将生成可执行PHP源代码,使用来自nikic/php-parser的中间抽象语法树。这种中间格式可以帮助您将此库生成的代码与其他来自Middleware的包结合。

配置格式

构建提取器

akeneo:
  extractor:
    type: productModel
    method: all
    search:
      - { field: enabled, operator: '=', value: true }
      - { field: completeness, operator: '>', value: 70, scope: ecommerce }
      - { field: completeness, operator: '<', value: 85, scope: ecommerce }
      - { field: categories, operator: IN, value: winter_collection }
      - { field: family, operator: IN, value: [camcorders, digital_cameras] }
  logger:
    type: 'stderr'
  client:
    api_url: 'https://demo.akeneo.com'
    client_id: '2_5a3jtcvwi8w0cwk88w04ogkcks00o4wowwgc8gg4w0cow4wsc8'
    secret: '4ww9l30ij2m8wsw8w04sgw4wgkwc8gss0sgc8cc0o0goo4wkso'
    username: 'demo_9573'
    password: 516f3e3e5

构建加载器

akeneo:
  loader:
    type: productModel
    method: upsert
  logger:
    type: 'stderr'
  client:
    api_url: 'https://demo.akeneo.com'
    client_id: '2_5a3jtcvwi8w0cwk88w04ogkcks00o4wowwgc8gg4w0cow4wsc8'
    secret: '4ww9l30ij2m8wsw8w04sgw4wgkwc8gss0sgc8cc0o0goo4wkso'
    username: 'demo_9573'
    password: 516f3e3e5

使用方法

此库将为您构建一个与Akeneo API兼容的提取器或加载器。

您可以使用以下PHP脚本来测试和打印您配置的结果。

<?php

require __DIR__ . '/../vendor/autoload.php';

use Kiboko\Component\Flow\Akeneo;
use PhpParser\Node;
use PhpParser\PrettyPrinter;
use Symfony\Component\Console;
use Symfony\Component\Yaml;

$input = new Console\Input\ArgvInput($argv);
$output = new Console\Output\ConsoleOutput();

class DefaultCommand extends Console\Command\Command
{
    protected static $defaultName = 'test';

    protected function configure()
    {
        $this->addArgument('file', Console\Input\InputArgument::REQUIRED);
    }

    protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
    {
        $factory = new Akeneo\Service();

        $style = new Console\Style\SymfonyStyle(
            $input,
            $output,
        );

        $config = Yaml\Yaml::parse(input: file_get_contents($input->getArgument('file')));

        $style->section('Validation');
        $style->writeln($factory->validate($config) ? '<info>ok</info>' : '<error>failed</error>');
        $style->section('Normalized Config');
        $style->writeln(\json_encode($config = $factory->normalize($config), JSON_PRETTY_PRINT));
        $style->section('Generated code');
        $style->writeln((new PrettyPrinter\Standard())->prettyPrintFile([
            new Node\Stmt\Return_($factory->compile($config)->getNode()),
        ]));

        return 0;
    }
}

(new Console\Application())
    ->add(new DefaultCommand())
    ->run($input, $output)
;

另请参阅