Jump to content

Product Sort


Guest jgislermn

Recommended Posts

Guest truebrit1002

Hi,

I am trying to figure out how to get my products to soft by price (high to low) by default. Any ideas?

Thanks Much,

Jen :)

Hi, I've been looking into this too as I wanted to order by Catalogue ID (ie a custom order based around manufacturer's products).

It seems as if it's really easy in CC5. Go to the file \classes\catalogue.class.php and find line 616. I changed 'name' to 'cat_id', but you should change it to 'price'. Then save. You should notice the sort function will list products by the column you've specified.

Does that sound correct to everyone else (Cubecart guys?). I would hate to recommend a fix that isn't correct, but it sems to work for me.

Link to comment
Share on other sites

Hi,

I am trying to figure out how to get my products to soft by price (high to low) by default. Any ideas?

Thanks Much,

Jen :)

Hi, I've been looking into this too as I wanted to order by Catalogue ID (ie a custom order based around manufacturer's products).

It seems as if it's really easy in CC5. Go to the file \classes\catalogue.class.php and find line 616. I changed 'name' to 'cat_id', but you should change it to 'price'. Then save. You should notice the sort function will list products by the column you've specified.

Does that sound correct to everyone else (Cubecart guys?). I would hate to recommend a fix that isn't correct, but it sems to work for me.

I tried to use your hint to sort by in stock by default, but it doesn't seem to have worked.

$order['quantity'] = 'DESC';

Link to comment
Share on other sites

Guest truebrit1002

Hi,

I am trying to figure out how to get my products to soft by price (high to low) by default. Any ideas?

Thanks Much,

Jen :)

Hi, I've been looking into this too as I wanted to order by Catalogue ID (ie a custom order based around manufacturer's products).

It seems as if it's really easy in CC5. Go to the file \classes\catalogue.class.php and find line 616. I changed 'name' to 'cat_id', but you should change it to 'price'. Then save. You should notice the sort function will list products by the column you've specified.

Does that sound correct to everyone else (Cubecart guys?). I would hate to recommend a fix that isn't correct, but it sems to work for me.

I tried to use your hint to sort by in stock by default, but it doesn't seem to have worked.

$order['quantity'] = 'DESC';

I think you need to use $order['stock_level'] = 'DESC';

Quantity is usually "1" unless you've changed it.

Link to comment
Share on other sites

Hi,

I am trying to figure out how to get my products to soft by price (high to low) by default. Any ideas?

Thanks Much,

Jen :)

Hi, I've been looking into this too as I wanted to order by Catalogue ID (ie a custom order based around manufacturer's products).

It seems as if it's really easy in CC5. Go to the file \classes\catalogue.class.php and find line 616. I changed 'name' to 'cat_id', but you should change it to 'price'. Then save. You should notice the sort function will list products by the column you've specified.

Does that sound correct to everyone else (Cubecart guys?). I would hate to recommend a fix that isn't correct, but it sems to work for me.

I tried to use your hint to sort by in stock by default, but it doesn't seem to have worked.

$order['quantity'] = 'DESC';

I think you need to use $order['stock_level'] = 'DESC';

Quantity is usually "1" unless you've changed it.

I'll try that, but we only have one of each, so quantity should have sorted it.

Link to comment
Share on other sites

LOL! Our Out of Stock items still show in the catalog on purpose (I assumed they would be quantity=0), but it would be better if they appeared at the end of the listings for someone who is browsing. We run a free Lost Toy Search Service, so if an item is out of stock we want to be able to help people find one somewhere else, or contact them when we get one back in stock.

Since it worked so well for you I'll play with it some more using stock_level. THAT WORKED!! Thanks for the feedback!!

Link to comment
Share on other sites

Guest truebrit1002

LOL! Our Out of Stock items still show in the catalog on purpose (I assumed they would be quantity=0), but it would be better if they appeared at the end of the listings for someone who is browsing. We run a free Lost Toy Search Service, so if an item is out of stock we want to be able to help people find one somewhere else, or contact them when we get one back in stock.

Since it worked so well for you I'll play with it some more using stock_level. THAT WORKED!! Thanks for the feedback!!

Glad to help. However I now realize that we should really be making amendments to the Cubecart code using PHP hooks. So I'll see if I can get it to do the same thing using one of these. Then you won't have to edit the existing code every time an update comes along!

Link to comment
Share on other sites

LOL! Our Out of Stock items still show in the catalog on purpose (I assumed they would be quantity=0), but it would be better if they appeared at the end of the listings for someone who is browsing. We run a free Lost Toy Search Service, so if an item is out of stock we want to be able to help people find one somewhere else, or contact them when we get one back in stock.

Since it worked so well for you I'll play with it some more using stock_level. THAT WORKED!! Thanks for the feedback!!

Glad to help. However I now realize that we should really be making amendments to the Cubecart code using PHP hooks. So I'll see if I can get it to do the same thing using one of these. Then you won't have to edit the existing code every time an update comes along!

That would be fantastic! I know the Hooks are important, but I haven't a clue how to make use of that process.

Link to comment
Share on other sites

Guest jgislermn

For the life of me, I cannot figure out why this sorting is not working.

Here is the code from the catalogue.class.php file...... Any ideas?

if (($result = $GLOBALS['db']->query('SELECT I.product_id FROM `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_category_index` as I, `'.$GLOBALS['config']->get('config', 'dbprefix').'CubeCart_inventory` as INV WHERE I.cat_id = '.$category_id.' AND I.product_id = INV.product_id AND INV.status = 1')) !== false) {

$this->_category_count = $GLOBALS['db']->numrows();

if (isset($_GET['sort']) && is_array($_GET['sort'])) {

foreach ($_GET['sort'] as $field => $direction) {

$order[$field] = (strtolower($direction) == 'asc') ? 'ASC' : 'DESC';

break;

}

} else {

$order['price'] = 'DESC';

}

foreach ($result as $product) {

$list[] = $product['product_id'];

}

foreach ($GLOBALS['hooks']->load('class.catalogue.category_product_list') as $hook) include $hook;

$productList = $this->getProductData($list, 1, $order, $per_page, $page, true);

}

return (isset($productList) && is_array($productList)) ? $productList : false;

}

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.

×
×
  • Create New...