Table of Contents
1. First, let’s explain why we need to analyze the category.php file.
(1) The reasons are as follows:
(2) What we hope to achieve is:
2. Then, let’s first take a look at what the demand is now? (For multi-condition filtering, please refer to JD.com, Suning, Gome, etc.)
Home Backend Development PHP Tutorial [PHP open source product] One of the analysis of the product filtering function of Ecshop (mainly analyzing category.php)_PHP tutorial

[PHP open source product] One of the analysis of the product filtering function of Ecshop (mainly analyzing category.php)_PHP tutorial

Jul 13, 2016 am 10:41 AM
ecshop php host product analyze Function merchandise accomplish Open source of filter

1. First, let’s explain why we need to analyze the category.php file.

(1) The reasons are as follows:

①I am curious about the implementation of the shopping mall product filtering function;

② I am more interested in the design of data tables for products in the mall. (This function involves interaction with the database, and has a certain connection with the design of the data table in the database);

③The multi-condition (attribute) filtering function is needed in many websites today and is very widespread (such as: general mall websites, group purchase websites, real estate websites, information classification websites, etc.).

(2) What we hope to achieve is:

① Be able to have a preliminary understanding of the multi-condition filtering function. (At least if you do it yourself, you can achieve it quickly);

②In the implementation of multi-condition filtering, how should the database be designed to be more optimized and reasonable (refer to previous experience);

③Have an understanding of some strategies or techniques in multi-condition screening (will summarize a few points)

2. Then, let’s first take a look at what the demand is now? (For multi-condition filtering, please refer to JD.com, Suning, Gome, etc.)

①Jingdong Mall’s product filtering function (screenshot):

②Suning Mall’s product filtering function (screenshot)

③Gome Online’s product filtering function (screenshot)

Supplement: In fact, to observe this function, we must also think about the address bar. I will omit it here. After all, it will be simpler if we analyze it this way. The above examples are just an introduction. I will improve it later.

④ECSHOP’s product filtering function is implemented, and the display details (screenshot + text) are as follows:

1) First, my local server has a virtual host address for the ecshop demo website installed on this machine:

"GSM mobile phone" category in the navigation bar. As follows:

If I want to view phones branded "Nokia", then click on the "Nokia" tab:

The access address is:

The result page is:

The access address is:

The result page is:

Analysis: From the changes in the address bar and screenshots above, we can initially see what ecshop’s multi-condition search method is like.

Conjecture 1: Every time the user clicks on the condition (attribute) to filter products, the search address bar will change. Why does the address bar change? In the final analysis, it must be for each product. The hyperlink address of the attribute's a tag has been changed. And every time you click, it will change according to the different search conditions.

Thus we know that the hyperlink of this attribute is dynamically generated. The ecshop background must have done a lot of judgment and finally generated a hyperlink address for each product attribute to prevent the last search condition from being lost.

Conjecture 2: What is the basis for calculating the price range of a product? It is still set up manually in the background. The price range of JD.com’s products seems to be very regular, which is quite different from the price range of ecshop. Don't worry about so much, let's study ecshop first.

Conjecture 3: Parameter filter_attr=163.0.160.0 The numbers in must represent the following: select all of them under the color, screen size, phone mode, and appearance style attributes. Which ones are worth it?

----> With these questions, let’s directly study how ecshop implements the above multi-condition search function. . . GO. . .

First, we go to the ecshop website to change the directory, find the category.php file, and open it to study it.

[PHP open source product] One of the analysis of the product filtering function of Ecshop (mainly analyzing category.php)_PHP tutorial ('IN_ECS', (() . '/includes/init.php' ((DEBUG_MODE & 2) != 2 ->caching = ((['id' = (['id' ((['category' = (['category' } ecs_header("Location: ./n" If there is no this parameter, it means that this parameter is not used to search, and a default value is given to it by default. = (['page']) && (['page']) > 0 ? (['page']) : 1 = (['page_size']) && (['page_size']) > 0 ? (['page_size']) : 10 = (['brand']) && (['brand']) > 0 ? (['brand']) : 0 = (['price_max']) && (['price_max']) > 0 ? (['price_max']) : 0 = (['price_min']) && (['price_min']) > 0 ? (['price_min']) : 0 = (['filter_attr']) ? ((['filter_attr'])) : '0' = ( = () ? '' : ('.', ( = ['show_order_type'] == '0' ? 'list' : (['show_order_type'] == '1' ? 'grid' : 'text' = ['sort_order_method'] == '0' ? 'DESC' : 'ASC' = ['sort_order_type'] == '0' ? 'goods_id' : (['sort_order_type'] == '1' ? 'shop_price' : 'last_update' = ((['sort']) && (((['sort'])), ('goods_id', 'shop_price', 'last_update'))) ? (['sort']) : = ((['order']) && (((['order'])), ('ASC', 'DESC'))) ? (['order']) : = ((['display']) && (((['display'])), ('list', 'grid', 'text'))) ? (['display']) : ((['ECS']['display']) ? ['ECS']['display'] : = (, ('list', 'grid', 'text')) ? : 'text' ('ECS[display]', , gmtime() + 86400 * 7 = ('%X', ( . '-' . . '-' . .'-' . .'-' . . '-' . . '-' . ['user_rank'] . '-' . ['lang'] .'-'. . '-' . . '-' . . '-' . (!->is_cached('category.dwt', = get_children( = get_cat_info(
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

To work on file upload we are going to use the form helper. Here, is an example for file upload.

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

In this chapter, we are going to learn the following topics related to routing ?

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

Validator can be created by adding the following two lines in the controller.

See all articles