3

I'm creating Product create / Edit API for admin.

In product edit API some attributes are in custom_attribute section(most of newly create) some are in extension_attribute and remain are directly within attribute code i 'm passing in the payload.

My question when creating Product how can I separate which attributes are within which section.directly,custom_attribute section or within extension_attribute section.because an at a time of product creation I can not separate attributes in section by using attribute set.

enter image description here

0

2 Answers 2

2
+100

Let's take them step by step:

  • top level attributes (name, sku, price, ...): this are the attributes that have a setter / getter in Magento\Catalog\Api\Data\ProductInterface. But they have to be attributes. For example there is a getter getOptions that gives you the custom options of the product. That one is not an attribute getter.
  • extension attributes: these are entities (or fields) related to the product that you don't store in the main product tables (catalog_product_entity_*). You will find them defined in the extension_attributes.xml files for the entity Magento\Catalog\Api\Data\ProductInterface. If you want to know all of them look in the for the string extension_attributes for="Magento\Catalog\Api\Data\ProductInterface" in all extension_attributes.xml files. You can add one or more yourself following the same procedure.
  • custom attributes. All other product attributes that do not appear in the top level.
2

Here is my short answer (I will update later)

For product custom attributes:

  • Those attributes will be added to custom_attributes "automatically". And, they are eav attributes.
  • You can find them in eav_attribute table.
  • is_user_defined is true (1) in eav_attribute.

For product extension attributes, you need:

Product extension attribute is more complicated than custom attribute.

Marius's answer is more clear.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.