官术网_书友最值得收藏!

Working with attribute sets

Magento has a flexible system to work with products. When you sell, for example, a board game or a computer, the specifications of each product are different. For a board game, information such as age and duration is relevant. For a computer, a lot of technical specifications are relevant, such as the CPU power, disc size, and so on.

To cover this, Magento 2 comes with a system called product templates, which can be compared with attribute sets in Magento 1.

A product template is a specification of product attributes that you can assign to products.

Getting ready

In the backend, we will use the pages Stores | Attributes | Product and Stores | Attributes | Attribute Set.

We will create a newproduct attribute and a new product template (such as an attribute set) that we can use in new products.

How to do it

In the following steps, we will create an extra product attribute that we can use in a product template:

  1. Navigate to Stores | Attributes | Product in the backend, and click on the Add New Attribute button.
  2. Populate the form with the following instructions:
    • Default label: Available from (This label will be used to identify the attribute)
    • Catalog Input Type for Store Owner: Date (this is the type of the attribute)
  3. Click on Save and Continue Edit and the attribute will be saved. You will see that the Attribute Code field is prepopulated with a code that is generated from the label.
  4. Additionally, we can set the following values:
    • Values required: No
    • Scope: Store View (with this setting, we create the possibility to specify separate values for each store view)
    • Default value: Leave this field empty
    • Unique value: No
  5. In the Manage Labels tab, we can set the label that will be displayed on the product detail page. If left empty, the attribute label will be used.
  6. In the Storefront Properties tab, we can set the following properties:
    • Use in search: No
    • Comparable on Storefront: No
    • Use for Promo Rule Conditions: No
    • Allow HTML Tags on frontend: No
    • Visible on Catalog Pages on Storefront: No
    • Used in Product Listing: No
    • Used for Sorting in Product Listing: No
  7. Click on Save Attribute; this will save the attribute.
  8. The next step is to create an Attribute Set to which will assign a product to. In the backend, navigate to Stores | Attributes | Attribute Set.
  9. Click on the Add Attribute Set button and fill in the form, as follows:
  10. Clicking on Save will open the overview page.
  11. Create a group named Game specific data and drag the available_from and manufacturer attributes to it. The overview will look as follows:
  12. Save the Attribute Set.
  13. Navigate to Product | Catalog and create a new product by clicking on the New Product button.
  14. Select the right Attribute Set in the form, as shown in the following screenshot:
  15. When selecting the product template, you will see that the Game specific data tab appears in the product tab, as shown in the following screenshot:

How it works

Product attributes and Attribute Sets are used when you work with multiple families of products. In the sample data of our shop, there are more attribute sets available for bags, clothing, and more.

With Attribute Sets, you can make groups of attributes for every product family. When creating a product attribute, you have to choose the type of the attribute, which can be one of the following:

  • Text field
  • Text area
  • Date
  • Yes/No
  • Multiple select
  • Dropdown
  • Price
  • Media image
  • Fixed Product Tax

Tip

When you want to use an attribute as a filter in the left navigation on the category pages, this attribute must have the type Dropdown, Multiple Select or Price.

主站蜘蛛池模板: 闻喜县| 衡南县| 苏尼特左旗| 沭阳县| 屏山县| 丁青县| 隆林| 大安市| 漠河县| 四子王旗| 湘阴县| 长汀县| 桓仁| 平罗县| 沙湾县| 邵阳市| 和顺县| 渝中区| 濮阳市| 太仓市| 海原县| 上杭县| 西畴县| 库伦旗| 屏山县| 油尖旺区| 丘北县| 六安市| 平邑县| 抚宁县| 永州市| 中西区| 宣化县| 正阳县| 永靖县| 环江| 元朗区| 新竹市| 玉门市| 台中市| 年辖:市辖区|