Home>

The ECCUBE 2.12.6 operates a client EC site.
I am a beginner of PHP, database, etc. I hope you can ask questions with a wide heart.

In the product list, we were able to implement price order, stock order, etc.
In the default display when opening the product list,
I would like to rearrange the items in stock and in the order in which they were registered.
I saw a variety of blog posts, but I didn't know how to solve it.
Please help.

Applicable source code

/data/class/pages/products/LC_Page_Products_List.php

/* Display product list */
function lfGetProductsList ($searchCondition, $disp_number, $startno, $linemax,&$objProduct) {

$arrOrderVal = array ();

$objQuery =&SC_Query_Ex :: getSingletonInstance ();
// Display order
switch ($this->orderby) {
// Sales price in ascending order
case'price&apos ;:
$objProduct->setProductsOrder ('price02&apos ;,'dtb_products_class&apos ;,'ASC');
break;

// Sales price in descending order
case'price2&apos ;:
$objProduct->setProductsOrder ('price02&apos ;,'dtb_products_class&apos ;,'DESC');
break;

// Newest
case'date&apos ;:
$objProduct->setProductsOrder ('create_date&apos ;,'dtb_products&apos ;,'DESC');
break;

// In stock
case'stock&apos ;:
$objProduct->setProductsOrder ('stock&apos ;,'dtb_products_class&apos ;,'DESC');
break;

// Out of stock
case'stock2&apos ;:
$objProduct->setProductsOrder ('stock&apos ;,'dtb_products_class&apos ;,'ASC');
break;

default:
$objProduct->setProductsOrder ('stock&apos ;,'dtb_products_class&apos ;,'DESC');
break;
}

  • Answer # 1

    If it is the default or$_ GET ["order"]is blank or not specified, the default will be listed
    If something exists in $_GET ["order"], it will be.

    ? order = xxxxx links will be sorted.

    If you need more than one order, do you need to remodel SC_Product

    You need to create order by using setOrder of SC_Query.