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

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.

主站蜘蛛池模板: 唐海县| 广水市| 柳林县| 宁明县| 平度市| 延津县| 富锦市| 吐鲁番市| 新沂市| 松滋市| 盐津县| 涿鹿县| 仁化县| 齐齐哈尔市| 上高县| 南川市| 清水县| 扶沟县| 安溪县| 江孜县| 桐城市| 灵宝市| 高要市| 梁河县| 阳高县| 赤城县| 磴口县| 永康市| 海盐县| 进贤县| 青浦区| 潢川县| 漳浦县| 恭城| 沾益县| 淳化县| 萨嘎县| 噶尔县| 梁平县| 鄂托克前旗| 根河市|