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

Configuring the catalog defaults

One of the first things is to configure some default catalog settings to the preferred values. We will cover all the configuration values that are possible in a Magento 2 installation.

We will go through the available configurations and change some values to the recommended settings.

Getting ready

Open your frontend and log into the backend in a separate browser tab. We will modify some configuration values to the recommended settings. When changing a configuration value, we can check what happens in the frontend.

How to do it

In the next steps, we will take a look at the catalog settings:

  1. In the backend, navigate to Stores | Settings | Configuration. Open the Catalog menu, as we can see in the following screenshot:
  2. Open the Product Fields Auto-Generation section. In this section, we can configure the behavior of the generation of SKU and metadata. When we add the following values for the Mask for Meta Keywords, the SKU, name, and the string "Magento" will be generated when saving a product:
    • {{sku}}, {{name}}, Magento
  3. Open the Storefront section and set the following values:
    • List mode: grid (by default, this shows the products in a grid or list)
    • Products per page on Grid allowed values: 12, 24, 36
    • Products per page on Grid default value: 24

      Note

      When changing the allowed and default value for a grid page, ensure that you can divide the numbers by the number of products that fit in a row in your theme. Otherwise, the last row of products will not be complete.

    • Products per page on List allowed values: 10, 20, 30, 40
    • Products per page on List default value: 10
    • Allow all products per page: No

      Note

      When you have a large number of products, it is not recommended to set the Allow all products per page option to Yes. When you have 2000 products and you want to show all the products on a single page, you will generate an enormous HTML output that can cause memory issues.

    • Product listing Sort by: price
    • Use Flat Catalog Category: No
    • Use Flat Catalog Product: No
    • Allow Dynamic Media URL's in Products and Categories: Yes
  4. Enable the product reviews for guests. This allows everyone to write a review about a product. When this is enabled, a review form will appear on the product review page.
  5. Open the Product Alerts section to configure product alert e-mails that will be sent when the price or stock changes.
  6. We will configure a stock alert with the following settings:
    • Allow alert when product price changes: No
    • Allow alert when product comes back in stock: Yes

    Note

    The previous configurations will send stock alert e-mails (a stock alert is triggered when a product becomes available in stock) to the subscribed e-mail addresses.

  7. We can set the values for Product Alerts Run settings in the next section. We will configure a daily task at 04:00 hours to send the alert e-mails:
    • Frequency: Daily
    • Start time: 04:00:00
  8. Leave the Product Image Placeholders options as they are. If we want, we can set a default image that will be shown when a product has no image or the image is not found. The best way is to set the placeholder images in the theme.
  9. In the Recently Viewed/Compared Products tab, set the following values:
    • Show for current: Website

      Note

      This will show the recent products you viewed over all stores and store views in the website.

    • Default recently viewed count: 5
    • Default recently compared count: 5
  10. In the Price tab, set the Catalog Price Scope option as Global. For this tutorial, we don't need different prices for each store view. When Price Scope is set to Global, we can only configure one global price for a product, which will be the same in all store views.
  11. In the Layered Navigation section, we will modify some settings to customize the left navigation for the category pages:
    • Display product count: Yes
    • Price navigation step calculation: Automatic (this will equalize price ranges)
  12. By making these settings, the price steps will always have the same increment.
  13. Open the Category Top Navigation section, and set Maximal Depth to 3. This means that the navigation will be shown with a maximum of three levels.
  14. In the Changing the URL of a product page recipe, we will look at the Search Enginge Optimization step.
  15. Configure the Catalog Search section as follows:
    • Minimal Query Length: 3
    • Maximum Query Length: 128
    • Search Engine: MySQL
    • Apply Layered Navigation if Search Results are Less Than: 0

    Note

    If a search result shows a lot of products, the generation of the layered navigation slows down the pageload. With this setting, you can disable the layered navigation if the results count is higher than the configured value.

  16. Don't forget to save the configuration by clicking on the Save Config button.

How it works

All these settings are saved in the configuration table of Magento. The frontend files for the catalog pages will pick up these settings and render the output based on these settings.

When you add extra functionality to the category page, you can easily extend the configuration with extra parameters. More information about extending the configurations is given in the Extending the system configuration recipe of Chapter 6, Magento Backend.

主站蜘蛛池模板: 南宫市| 天津市| 南靖县| 孝义市| 山丹县| 姜堰市| 登封市| 遂昌县| 浏阳市| 新民市| 上虞市| 安徽省| 巴彦县| 台安县| 商都县| 和田市| 大关县| 大新县| 会同县| 顺昌县| 库伦旗| 华亭县| 通州区| 平武县| 铁力市| 西宁市| 荆门市| 遵化市| 巴南区| 闸北区| 黑水县| 芜湖县| 会宁县| 太康县| 乌鲁木齐市| 延川县| 黑龙江省| 康定县| 烟台市| 三原县| 无锡市|