background

In the electronic process of goods, the characteristics of goods can be described by multiple “attributes and corresponding attribute values”, and according to a group of attribute values, the unique commodity information can be confirmed. When selecting commodities, different attribute values correspond to different commodity information, whose name, price and prompt are different. For different attributes, it needs some algorithm to judge whether there are corresponding commodities in their combination after selection. Taking cleaning product selection as an example, a set of processing scheme for product selection by attribute classification is constructed. There will be single product and multiple product styles for different cleaning types. Single product selection is a combination of goods given multiple groups of similar attributes, and corresponding products are given after selecting and matching multiple different attributes. Only one service can be selected between multiple products at the same time, and the order can be placed according to the selected products, and the amount is determined according to the products. Multiple products for the use of different services can be superimposed, can be in a door-to-door period according to the need for free combination of orders, the amount of selected services for the superimposition. This scheme solves the problem of free cleaning product selection and has great versatility to similar product selection.

Treatment scheme

In this algorithm design, a commodity selection scheme is provided. By selecting different attributes, the corresponding commodity information is displayed in combination, and when selecting attributes, a hint is given on whether other attributes are optional. In this algorithm, the back-end provides the corresponding product information and attribute information at one time, and the attributes are combined in the front section to obtain the corresponding product, which reduces the time consuming caused by each interface query and the problems caused by network instability, and gives users a better experience.

In the process of commodity electronization, the general description method, SPu-standard Product Unit, is precipitate. Sku-stock keeping unit refers to different attributes of products. This article also uses general rules to describe goods.

The scheme is mainly divided into commodity pool, attribute pool data collation, data selection processing, display processing three parts. MVVM architecture is adopted. The Model layer is for formatting data information, and the standardized data format is unified as specified Model for the first time. Data processing, storage and calculation are handled by shoppingManager. And according to the product specification classification into single product selection and multiple product selection two basic styles, divided into singleManager and multipleManager, respectively processing data logic.

Finishing process

Main processing process:

  1. The initial data is captured externally and then standardized into a standard model. Distinguish single product or multiple product styles by type. The data is then processed according to different styles.
  2. Single product selection, mainly for the combination of different attributes to match different goods, and display the selection results. The processing focus is mainly on the initial formatting of attributes and product selection of mutually exclusive logic. The algorithm of the two parts will be explained later. Page presentation is controlled by the Manager, and the interaction is mainly property selection and submission.
  3. Multi-product selection, mainly for product type judgment, shopping cart function. Product judgment refers to the presentation of different styles and interactive buttons based on product specifications. Shopping cart refers to the record and update of the product selected by the user. Page display is controlled by manager, and the interaction is mainly product selection, deselecting, clearing options, merging orders.
  4. After operation, users go to the background to obtain the latest price and preferential information according to the product information, and click “place the order” to carry the selected product information to the “place the order” page.

Formatting process

The main process is as follows:

  1. According to the acquired attribute information and product information, the unified attribute model and commodity model are constructed according to the customized model to facilitate the unified processing of subsequent data. The attribute list contains all attribute information in the same attribute type and attribute priority field. Priority is used for subsequent sorting. The product list contains product information and product attribute information. You then need to position the goods based on the attribute information.
  2. First, the attributes are sorted according to their priorities, which determines the preservation order of different attributes in the following order to ensure that the keys of continuously typed attributes will not be misplaced.
  3. When entering the system for the first time, if no data is selected and there is a default product, the property corresponding to the default product is set as the selected property and matches the subsequent logic.
  4. All products are stored in the form of dictionary, and the key is the string composed by the corresponding attribute code of the product sorted according to the priority, and the value is the current product model. The storage purpose is to facilitate the search for product information based on the selected attribute.

Item selection mutually exclusive algorithm

The main process is as follows:

  1. Commodity selection algorithm is used to match corresponding product information for display according to selection attributes. And the logic that calculates whether other attribute values are optional. When selecting the default product for the first time, or when the user switches an attribute value, it needs to be recalculated.
  2. The initial condition of the algorithm is always the list of all attributes and always the priority relationship. Product dictionary, selected set of property values.
  3. Product matching: Construct an attribute string based on the selected attribute, and extract product information from the product dictionary based on the attribute string.
  4. Attribute mutual exclusion: for the convenience of reminding users of product options, after each match, it will judge whether there is an item based on this attribute and other selected attribute sets. If there is no item, the attribute will be grayed out and the optional style will be displayed. Give the user a hint.
  5. Price information, discount information and other values that are easy to change, according to the information of selected goods, the way of querying from the interface to ensure the accuracy of data.

conclusion

The above is the main content of the attribute selection processing scheme. The commodity selection algorithm is used to match the corresponding product information for display according to the selected attributes. And the logic that calculates whether other attribute values are optional. When selecting the default product for the first time, or when the user switches an attribute value, it needs to be recalculated. The initial condition of the algorithm is always the list of all attributes and always the priority relationship. Product dictionary, selected set of property values. The product matching logic mainly constructs an attribute string based on the selected attribute. Based on the attribute string, the product information is extracted from the product dictionary. For the convenience of reminding the user of product options, after each match, it will judge whether there is a product based on this attribute and other selected attribute sets. If there is no product, the attribute will be gray and the optional style will be displayed. Give the user a hint, and mutually exclusive display gives the user a hint of goods, but also given the user to choose the range, the optional attributes can be found for goods, can be directly stored, reduce a convenient query, simplify logic and improve efficiency. Price information, discount information and other values that are easy to change, according to the information of selected goods, the way of querying from the interface to ensure the accuracy of data.

Author: Wu Liuyan, Jiang Zhiwei, Freely Big front End R&D Center

Recruitment information

Free big front end R&D center recruiting new students!

FE/IOS/Android engineers look over

Company benefits include:

  • Five insurances and one housing fund in full, plus commercial insurance
  • Free gym + annual physical examination
  • 10 percent discount for rent near the company
  • 2 promotions per year

Office location: Beijing Jiuxianqiao Putian Industrial Science and Technology Park welcome you to join us! Please send your resume to [email protected]!