U
U
Ultraice2016-04-21 18:14:19
PHP
Ultraice, 2016-04-21 18:14:19

How to automatically link products to categories?

The competent implementation of linking goods to categories is interesting . For example, according to the property of the product year, bind it to the category 2016. Keep in mind that new categories may appear. For example, in the 2016 category, under the women's category. Accordingly, there are goods with a combination of properties year = 2016 and gender = f.
I saw the implementation in Bitrix. There, each category had a filter field - php code that was executed by eval. The cron ran the script, looked through all the categories and all the products, and made a binding if the filter matched.
I think this is not the right solution, maybe someone knows better?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stanislav Makarov, 2016-04-21
@Ultraice

The correct solution, from a theoretical point of view, is a deductive database . You have a main database with facts about products (that is, with their attributes), and based on the given rules, you build new derivative statements about the entry of a particular product into a category.
Your categories are essentially sets/classes defined with a predicate. Each of your filters is a predicate for a product to be included in the set. The hierarchy of categories is the usual inheritance of classes. To implement inheritance, you need to check the predicate for the child category and also check all the predicates in the parent categories. Then in the category " 2016 " you write the condition " year = 2016 ", and in the child category women write "gender = x " and both conditions should be checked for each product.
So you need some simple language or way to write predicates (you might want logical operators and/or/not), a hierarchy of categories, where a predicate in the above language is attached to each category, and an engine that will link products to categories, or even, if there are few products, query them on the go, translating predicates into SQL filters (well, or another query language for the base in which you have goods). We had a project - an aggregator of goods from online stores, we did something like categories. They even managed to add support for some built-in functions in predicates, so that, for example, it would be possible to define it in one category or another by part of the name of the product (or vice versa, exclude it from the category in order to distinguish plumbing gaskets from any others).

T
ThunderCat, 2016-04-21
@ThunderCat

Rather, you do not have a category, but a property of 2016, such properties fit through the link table into the property table, respectively, we read a many-to-many relationship.

X
xmoonlight, 2016-04-21
@xmoonlight

Your category is the name of the faceted filter.
Everything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question