Jump to content

How can I change the sale items box list of products?


Dodgebill
 Share

Recommended Posts

I was hoping somebody would know how to change the list of products that show up in the sale items box. Right now that are sorted by Product ID and then highest savings. This means only the first 10 or 15 Product IDs are ever shown in this box. Seems really limiting

I found the code that deals with this function but cannot get it to change. There has to be someway to set an array function for a different parameter other than Product ID. I would love to change it to most popular or lasted added or something like that.

Any ideas how to do this?

Link to comment
Share on other sites

You can try this:

/classes/gui.class.php
Find near line 1205:

// Loop and merge group price into Retail Prices
if (!empty($unsorted_products) && is_array($unsorted_products)) {
	foreach ($unsorted_products as $product) {
		$sorted_products[$product['saving'].$product['product_id']] = $product;
	}
	krsort($sorted_products);
} else {
	$sorted_products = false;
}

Change to:

// Loop and merge group price into Retail Prices
if (!empty($unsorted_products) && is_array($unsorted_products)) {
	foreach ($unsorted_products as $product) {
// UNCOMMENT THE DESIRED SORTING METHOD
		// $sorted_products[$product['saving'].$product['product_id']] = $product; // USE SAVINGS
		// $sorted_products[$product[$GLOBALS['config']->get('config','product_sort_column')].$product['product_id']] = $product; // USE ADMIN SORT SETTING
	}
// UNCOMMENT THE DESIRED SORTING DIRECTION
	// krsort($sorted_products); // STANDARD HI to LOW SORT
	// if($GLOBALS['config']->get('config','product_sort_direction') == "ASC") { ksort($sorted_products); } else { krsort($sorted_products); } // USE ADMIN SORT SETTING
} else {
	$sorted_products = false;
}

You will uncomment (remove the leading slash-slash) from one of two choices in each of two locations.

Link to comment
Share on other sites

I have installed the new code and it works fine but it does not do what I was really hoping it would. I am trying to get a list of products that are not just the first 10 or 15 product IDs. I was hoping to be able to select another parameter to select the list from, not just reorder the existing list. If you change 'product_Id' to something else nothing changes.

I found that part of the code as well when I was working on this but I was unable to make any changes that did anything to change the list of products displayed other that sort order. Seems we have found different solutions to the same question with the same result. Although this does limit the list to just 7 items for some reason..... I have the admin setting set at 15 currently.

 

I think that the answer lies in how the list is pulled from the DB. There is no sort or array command in the DB call for the sale items list. This will just pull the first rows until the preset number is achieved, correct? I have tried adding a sort order but with no luck. Any ideas?

Link to comment
Share on other sites

I see. Please try:

/classes/gui.class.php
Find near line 1194:

// Get Retail Prices second
if (isset($sale_sql_standard_select) && ($standard_pricing = $GLOBALS['db']->query('SELECT `price`, `sale_price`, `product_id`,`description`,`name`, '.$sale_sql_standard_select.' AS `saving` FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory` WHERE '.$sale_sql_standard_where.' AND `status` = \'1\' '.$not_on_sale.' LIMIT '.$GLOBALS['config']->get('config', 'catalogue_sale_items'))) !== false && is_array($standard_pricing)) {

The query is (split across multiple lines for clarity):
$GLOBALS['db']->query(
'SELECT `price`, `sale_price`,
        `product_id`, `description`, `name`,
        '.$sale_sql_standard_select.' AS `saving` 
 FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory` 
 WHERE '.$sale_sql_standard_where.' 
 AND `status` = \'1\' 
 '.$not_on_sale.' 
 LIMIT '.$GLOBALS['config']->get('config', 'catalogue_sale_items')
)

Change the query to:
$GLOBALS['db']->query(
'SELECT `price`, `sale_price`,
        `product_id`, `description`, `name`,
        '.$sale_sql_standard_select.' AS `saving` 
 FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory` 
 WHERE '.$sale_sql_standard_where.' 
 AND `status` = \'1\' 
 '.$not_on_sale.' 
 '.$order_by.'
 LIMIT '.$GLOBALS['config']->get('config', 'catalogue_sale_items')
)

Then:

Find near line 1191:
$not_on_sale = isset($not_on_sale) ? 'AND `product_id` NOT IN ('.implode(',', $not_on_sale).') ' : '';

On the blank line below that, add:
$order_by = ' ORDER BY '.$GLOBALS['config']->get('config','product_sort_column').' '.$GLOBALS['config']->get('config','product_sort_direction').' ';

The admin setting for product sort parameters has been injected into the query.

Link to comment
Share on other sites

That worked. I will see if I can change out 'product sort column' to a new 'sale sort column' in config so I can have it different than the category pages layout but other than that it's fantastic! Thank you so much for your help, again.

Bill Cooke

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...