如何在 PimCore 5+ 中为包含许多不同类型的产品和属性的大型目录建模
How to model a large catalogue with many different types of products and attributes in PimCore 5+
我是一名经验丰富的全栈网络开发人员,但对 PimCore 还是个新手。我在 PimCore 中组织了一个包含多种类型项目的大型目录,并多次查看了文档,但我仍然不知道如何解决我将产品数据组织到 classes 中的两个基本问题。我希望一些更有经验的 PimCore 用户或开发者可以对此有所启发。
问题 1:如何对适用于目录中所有产品的一般产品属性建模。
我目录中的所有产品都有名称和描述,所以我认为制作具有这些字段的产品 class 并制作我所有的特定产品 classes subclasses of that Product class 所以我不必为每个 subclass 单独添加名称和描述字段。
我尝试设置它,但在特定子class的对象编辑器中,我添加到通用产品超级class的布局字段没有显示。我在这里错过了什么吗?我的方法真的有效吗?如果不是,PimCore 的建模方法是什么?
问题 2:如何最好地为具有多个选项的产品建模,即。超过一维的变体。
例如,有颜色和尺码选项的 T 恤(假设有 3 种颜色和 3 种尺码,总共有 9 种款式)。我想在对象树中创建一件 T 恤产品,然后为(自动)总共 9 个变体添加 3 个颜色选项和 3 个尺寸选项。我希望 T 恤作为单品出现在电子商务前端,让最终客户确定两种选择的价值。
我想知道是否有可能以允许我相互独立地指定 3 种颜色选项和 3 种尺寸的方式来做到这一点。我在文档中找到的示例都向我展示了一个完全扩展的对象树,涵盖了所有选项(例如,1 个 T 恤对象,每个尺寸有 3 个子对象,每个尺寸的每种颜色有 3 个子对象)。尽管数据继承有助于管理此信息,但仍然必须为每个尺寸选项更改一次可用颜色。我无法想象在 PimCore 中没有更好的方法来设置多个维度的对象变体,但几天的搜索让我一无所获。我在这里错过了什么吗?或者 PimCore 是否真的强制您为每个产品选项组合创建 objects/variants?如果不是,PimCore 的建模方法是什么?
希望在这方面有一点经验的人愿意对这两个问题有所了解。非常感谢!!
在 PimCore 论坛上收到了非常有用的答案,用户 fash:
Issue 1: Pimcore DataObject classes cannot inherit from each other. The way to go would be to create one product class (that
contains all common product attributes) and then use object bricks or
classification store groups to model category specific attributes.
Then on object level, the corresponding object brick or classification
store group can be added to the product object (depending on its
category or other criteria).
Issue 2: As you already noticed, the default way of dealing with different variants of a product is to create an object instance for
each variant and utilize data inheritance to reduce data maintenance
effort (like in the demo). Also as Andrew already pointed out, adding
some helper functionality like a generate variants button is easily
possible.
The reason why we create a unique data object for each variant most of
the time is, that normally each SKU has a unique product number and
also in terms of e-commerce it needs to be possible to reference the
exact variant that was ordered. As an alternative you of course could
use data structures like field definitions or block to follow your
approach and have to attributes (like color, size, etc.) and add
multiple values to them and then deal on the output channel with the
variant generation. It is really up to your use case and your system
what fits better.
An hybrid solution would be to define possible variants with variant
attributes, and then generate the actual object variants on the fly
when one is ordered.
我是一名经验丰富的全栈网络开发人员,但对 PimCore 还是个新手。我在 PimCore 中组织了一个包含多种类型项目的大型目录,并多次查看了文档,但我仍然不知道如何解决我将产品数据组织到 classes 中的两个基本问题。我希望一些更有经验的 PimCore 用户或开发者可以对此有所启发。
问题 1:如何对适用于目录中所有产品的一般产品属性建模。
我目录中的所有产品都有名称和描述,所以我认为制作具有这些字段的产品 class 并制作我所有的特定产品 classes subclasses of that Product class 所以我不必为每个 subclass 单独添加名称和描述字段。
我尝试设置它,但在特定子class的对象编辑器中,我添加到通用产品超级class的布局字段没有显示。我在这里错过了什么吗?我的方法真的有效吗?如果不是,PimCore 的建模方法是什么?
问题 2:如何最好地为具有多个选项的产品建模,即。超过一维的变体。
例如,有颜色和尺码选项的 T 恤(假设有 3 种颜色和 3 种尺码,总共有 9 种款式)。我想在对象树中创建一件 T 恤产品,然后为(自动)总共 9 个变体添加 3 个颜色选项和 3 个尺寸选项。我希望 T 恤作为单品出现在电子商务前端,让最终客户确定两种选择的价值。
我想知道是否有可能以允许我相互独立地指定 3 种颜色选项和 3 种尺寸的方式来做到这一点。我在文档中找到的示例都向我展示了一个完全扩展的对象树,涵盖了所有选项(例如,1 个 T 恤对象,每个尺寸有 3 个子对象,每个尺寸的每种颜色有 3 个子对象)。尽管数据继承有助于管理此信息,但仍然必须为每个尺寸选项更改一次可用颜色。我无法想象在 PimCore 中没有更好的方法来设置多个维度的对象变体,但几天的搜索让我一无所获。我在这里错过了什么吗?或者 PimCore 是否真的强制您为每个产品选项组合创建 objects/variants?如果不是,PimCore 的建模方法是什么?
希望在这方面有一点经验的人愿意对这两个问题有所了解。非常感谢!!
在 PimCore 论坛上收到了非常有用的答案,用户 fash:
Issue 1: Pimcore DataObject classes cannot inherit from each other. The way to go would be to create one product class (that contains all common product attributes) and then use object bricks or classification store groups to model category specific attributes.
Then on object level, the corresponding object brick or classification store group can be added to the product object (depending on its category or other criteria).
Issue 2: As you already noticed, the default way of dealing with different variants of a product is to create an object instance for each variant and utilize data inheritance to reduce data maintenance effort (like in the demo). Also as Andrew already pointed out, adding some helper functionality like a generate variants button is easily possible.
The reason why we create a unique data object for each variant most of the time is, that normally each SKU has a unique product number and also in terms of e-commerce it needs to be possible to reference the exact variant that was ordered. As an alternative you of course could use data structures like field definitions or block to follow your approach and have to attributes (like color, size, etc.) and add multiple values to them and then deal on the output channel with the variant generation. It is really up to your use case and your system what fits better.
An hybrid solution would be to define possible variants with variant attributes, and then generate the actual object variants on the fly when one is ordered.