PHP.50-TP Framework Mall Application Example-Front desk 2-product recommendation

Source: Internet
Author: User

Product recommendation

{snapped, new, boutique, hot} The effect is as follows

1, in the commodity table to increase the promotion price and promotion start time and end time Three fields, the field recommended floor and sorting in the back to use

Note: When adding a DateTime Type field, add the default value {DateTime range:1000-01-01 00:00:00 to 9999-12-31 23:59:59}; and turn off MySQL strict mode, Because Promote_price (decimal (10,2)) cannot insert a null value, it is recommended that the development phase be open

2. Form and Time Plugin

3. Modify the product model to allow receiving fields

4, the front desk to take out the recommended products

//Take out the item currently being promoted         Public functionGetpromotegoods ($limit= 5)        {            $today=Date(' y-m-d h:i '); return $this->field (' ID, goods_name, Mid_logo, Promote_price ')                ->where (Array(                ' Is_on_sale ' =Array(' eq ', ' 1 '), ' promote_price ' =Array(' GT ', 0), ' promote_start_date ' =Array(' ELT ',$today), ' promote_end_date ' =Array(' Egt ',$today),            ))->limit ($limit)            -Select (); }    //out of three recommendations {hot, boutique, new}         Public functionGetrecgoods ($recType)        {            return $this->field (' Id,goods_name,mid_logo,shop_price ')            ->where (Array(                ' Is_on_sale ' =Array(' eq ', ' 1 '), "$recType"=Array(' eq ', ' yes ')            ))            ->limit ($limit)            ->order (' Sort_num ') //Sort by sort_num field -Select (); }

5. Remove from the home/indexcontroller.class.php controller

6, index.html page loop output

Note: in order to be able to sort the goods more accurately , we can add a field sort_numfor the item, this field holds a number, the smaller the number , the higher the front

PHP.50-TP Framework Mall Application Example-Front desk 2-product recommendation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.