Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-8198: PIM training #2449

Draft
wants to merge 29 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
09a719f
[WIP] PIM training raw draft
adriendupuis Jul 31, 2024
e649798
[WIP] PIM training raw draft
adriendupuis Jul 31, 2024
60e5294
[WIP] PIM training raw draft
adriendupuis Jul 31, 2024
b46decd
[WIP] PIM training raw draft
adriendupuis Jul 31, 2024
c8f2464
[WIP] PIM training raw draft
adriendupuis Jul 31, 2024
c898b99
[WIP] PIM training: rework syllabus
adriendupuis Jul 31, 2024
7ccac99
011_product_modeling.md: Fix list indent
adriendupuis Sep 13, 2024
b8c22b1
011_product_modeling.md: Continue bike modeling exercise
adriendupuis Oct 2, 2024
66cdec2
021_product_pricing.md: Few notes for the future
adriendupuis Oct 2, 2024
121f4b9
011_product_modeling.md: Add a code generator example
adriendupuis Oct 4, 2024
67db240
PHP CS Fixes
adriendupuis Oct 4, 2024
6717a13
PIM training: Narrow down to modeling and sorting products.
adriendupuis Oct 9, 2024
4a66c69
011_product_modeling.md: Fix some vale warnings
adriendupuis Oct 9, 2024
a8702c8
011_product_modeling.md: UK Aluminium → US Aluminum
adriendupuis Oct 9, 2024
a2537b3
000_syllabus.md: Fix Ibexa.SpacingNestedList
adriendupuis Oct 9, 2024
e6844a5
PIM training: About data migration
adriendupuis Oct 10, 2024
66f1408
011_product_modeling.md: few notes
adriendupuis Oct 11, 2024
64c0c12
011_product_modeling.md: few notes
adriendupuis Oct 11, 2024
462bb5d
PIM training: draft ideas for APIs
adriendupuis Oct 15, 2024
c1305c7
011_product_modeling.md: About assets
adriendupuis Oct 16, 2024
69ceb26
021_product_exchange.md: Reorganize TOC, continue PHP API
adriendupuis Oct 17, 2024
af9c1bb
021_product_exchange.md: Fix Contracts namespace name
adriendupuis Oct 17, 2024
c226798
021_product_exchange.md: minor change
adriendupuis Oct 17, 2024
ef42e4e
021_product_exchange.md: Start REST API ToC, sort routes
adriendupuis Oct 17, 2024
a3f4afd
021_product_exchange.md: Fix a link to PHP API Ref
adriendupuis Oct 18, 2024
cb5e0ff
Merge branch 'master' into IBX-8198-PIM-training
adriendupuis Oct 18, 2024
566f1b2
011_product_modeling.md: More about translation
adriendupuis Oct 18, 2024
196a557
composer.json minimum-stability dev
adriendupuis Oct 18, 2024
9224832
Revert "composer.json minimum-stability dev"
adriendupuis Oct 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ibexa_product_catalog:
engines:
default:
type: local
options:
root_location_remote_id: ibexa_product_catalog_root
product_type_group_identifier: 'product'
variant_code_generator_strategy: 'per_product_type_code_generator'
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:
# …

App\CodeGenerator\Strategy\ProductTypeCodeGeneratorDispatcher:
arguments:
$defaultCodeGeneratorIdentifier: 'incremental'
$productTypeCodeGeneratorMap:
bike: 'bike'
tags:
- { name: 'ibexa.product_catalog.code_generator', type: 'per_product_type_code_generator' }

App\CodeGenerator\Strategy\BikeCodeGenerator:
tags:
- { name: 'ibexa.product_catalog.code_generator', type: 'bike' }
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace App\CodeGenerator\Strategy;

use Ibexa\Contracts\Core\Exception\InvalidArgumentException;
use Ibexa\Contracts\ProductCatalog\Local\CodeGenerator\CodeGeneratorContext;
use Ibexa\Contracts\ProductCatalog\Local\CodeGenerator\CodeGeneratorInterface;

final class BikeCodeGenerator implements CodeGeneratorInterface
{
public function generateCode(CodeGeneratorContext $context): string
{
if (!$context->hasBaseProduct()) {
throw new InvalidArgumentException('$context', 'missing base product');
}

$frameSize = $context->getAttributes()['frame_size'];
$wheelSize = $context->getAttributes()['wheel_diameter'];
$frameShape = $context->getAttributes()['frame_shape'][0];
$gearBundle = $context->getAttributes()['gear_bundle'];

return $context->getBaseProduct()->getCode() . "--$frameSize-$wheelSize-$frameShape-$gearBundle";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

namespace App\CodeGenerator\Strategy;

use Ibexa\Contracts\Core\Exception\InvalidArgumentException;
use Ibexa\Contracts\ProductCatalog\Local\CodeGenerator\CodeGeneratorContext;
use Ibexa\Contracts\ProductCatalog\Local\CodeGenerator\CodeGeneratorInterface;
use Ibexa\ProductCatalog\Local\Repository\CodeGenerator\CodeGeneratorRegistryInterface;

final class ProductTypeCodeGeneratorDispatcher implements CodeGeneratorInterface
{
private CodeGeneratorRegistryInterface $codeGeneratorRegistry;

private string $defaultCodeGeneratorIdentifier;

private array $productTypeCodeGeneratorMap;

public function __construct(CodeGeneratorRegistryInterface $codeGeneratorRegistry, string $defaultCodeGeneratorIdentifier = 'incremental', array $productTypeCodeGeneratorMap = [])
{
$this->codeGeneratorRegistry = $codeGeneratorRegistry;
$this->defaultCodeGeneratorIdentifier = $defaultCodeGeneratorIdentifier;
$this->productTypeCodeGeneratorMap = $productTypeCodeGeneratorMap;
}

public function generateCode(CodeGeneratorContext $context): string
{
if (!$context->hasBaseProduct()) {
throw new InvalidArgumentException('$context', 'missing base product');
}

$productTypeIdentifier = $context->getBaseProduct()->getProductType()->getIdentifier();
$codeGeneratorIdentifier = array_key_exists($productTypeIdentifier, $this->productTypeCodeGeneratorMap) ? $this->productTypeCodeGeneratorMap[$productTypeIdentifier] : $this->defaultCodeGeneratorIdentifier;

if ($this->codeGeneratorRegistry->hasCodeGenerator($codeGeneratorIdentifier)) {
return $this->codeGeneratorRegistry->getCodeGenerator($codeGeneratorIdentifier)->generateCode($context);
} else {
throw new InvalidArgumentException('$productTypeCodeGeneratorMap', "no code generator '$codeGeneratorIdentifier' registered");
}
}
}
51 changes: 51 additions & 0 deletions docs/trainings/commerce/pim/000_syllabus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---

Check warning on line 1 in docs/trainings/commerce/pim/000_syllabus.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/trainings/commerce/pim/000_syllabus.md#L1

[Ibexa.ReadingLevel] The grade level is 6.95. Aim for 8th grade or lower by using shorter sentences and words.
Raw output
{"message": "[Ibexa.ReadingLevel] The grade level is 6.95. Aim for 8th grade or lower by using shorter sentences and words.", "location": {"path": "docs/trainings/commerce/pim/000_syllabus.md", "range": {"start": {"line": 1, "column": 1}}}, "severity": "WARNING"}
description: PIM training
page_type: training
---

# PIM (Product Information Management)

## Syllabus

In this training, you learn how to create complex products locally, and to organize them.

| Section | Estimated | Description |
|:--------------------------------------------|----------:|:----------------------------------------------------------|
| [Product modeling](011_product_modeling.md) | X minutes | Learn about product types, products and product variants. |
| [Product shelving](012_product_shelving.md) | Y minutes | Organize your products with categories and catalogs. |
| [Product exchange](021_product_exchange.md) | Z minutes | Explore REST API, PHP API, and migrations. |

## Requirements

### Previous knowledge

- [Content management](content_management.md)
- [Content types](content_types.md) and [content items](content_model.md#content-items)
- [Taxonomy](taxonomy.md)
- [Templating](templating.md)

### Ibexa DXP edition

[[= product_name_headless =]] is the minimal edition required for this training.

- [[= product_name_headless =]] [[= latest_tag_4_6 =]]
- [[= product_name_exp =]] [[= latest_tag_4_6 =]]
- [[= product_name_com =]] [[= latest_tag_4_6 =]]

TODO: Make sure that everything used is in Ibexa DXP Headless scope, so to speak, ibexa/product-catalog. It mustn't use features from ibexa/storefront.

Check failure on line 35 in docs/trainings/commerce/pim/000_syllabus.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/trainings/commerce/pim/000_syllabus.md#L35

[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'
Raw output
{"message": "[Ibexa.VariablesGlobal] Use global variable '[[= product_name_base =]]' instead of 'Ibexa'", "location": {"path": "docs/trainings/commerce/pim/000_syllabus.md", "range": {"start": {"line": 35, "column": 44}}}, "severity": "ERROR"}

### Cluster elements

This training can be run on the minimal stack.

| Service | Required | Value |
|--------------:|:--------:|:-------------|
| Search engine | No | (Legacy) |
| Cache pool | No | (Filesystem) |
| HTTP cache | No | |

### Starting state

To follow this training, you must install code, configuration, and data on top of a fresh installation.

TODO: Experience clean install, or previous bike ride design and content?
Loading
Loading