-
- Thejosh13

-
Total Posts: 166
Joined: 2008-06-23
|
Its pretty shocking they still have not added such basic features. It makes me wonder what they are doing over there?
They must underestimate the performance effect on our stores of these kind of basic features.
I know the first product in each of my product pages is the most viewed product. If people come back a 2nd time I want to show them something different.
|
| |
-
- Posted: August 22 2008
-
| top
| # 16
-
|
 |
 |
 |
|
|
-
- davion

-
Total Posts: 13
Joined: 2008-05-03
|
Maybe someone will need it so I decide to put:
To get listed category products in Random way I changed Toolbar.php
and add random field (note I’ve add it first to make it by default)
$this->_availableOrder = array( 'random' => $this->__('Random'), 'position' => $this->__('Best Value'), 'name' => $this->__('Name'), 'price' => $this->__('Price') );
also we need to catch the moment it start to sort to provide it:
at function setCollection()
change from this:
public function setCollection($collection) { parent::setCollection($collection); if ($this->getCurrentOrder()) { $this->getCollection()->setOrder($this->getCurrentOrder(), $this->getCurrentDirection()); } return $this; }
to this:
public function setCollection($collection) { parent::setCollection($collection); if ($this->getCurrentOrder()) { if($this->getCurrentOrder() == 'random') { $this->getCollection()->getSelect()->order('rand()'); } else { $this->getCollection()->setOrder($this->getCurrentOrder(), $this->getCurrentDirection()); } } return $this; }
|
| |
-
- Posted: August 25 2008
-
| top
| # 17
-
|
 |
 |
 |
|
|
-
- bradsugar

-
Total Posts: 24
Joined: 2008-08-16
|
RPGShop - 16 June 2008 08:39 PM We need things sorted by product entered date since my industry is very front-line driven. So I wen and changed things to this:
$this->_availableOrder = array(
‘entity_id’ => $this->__(’Newest’),
‘name’ => $this->__(’Name’),
‘price’ => $this->__(’Price’)
);
And that actually worked. It shows products from newest to oldest books in that category. Thank god the default was to show newest to oldest (DESC).
This is definatly an option that should be added.
James
http://www.rpgshop.com
Good job...I really love this…
|
| |
-
- Posted: August 27 2008
-
| top
| # 18
-
|
 |
 |
 |
|
|
-
- BungleFeet

-
Total Posts: 11
Joined: 2008-08-20
|
Moshe - 25 October 2007 08:57 AM @macsmart: it’s not configurable from admin yet, take a look in app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php function getCurrentOrder() - it will take the first available. So you can either change this method or change available orders on line 41
Moshe, is there any way I can alter this code without invalidating my installation to updates? Can I place patched code in app/code/local and have Magento load the patched code instead?
Cheers,
Bungle
|
| |
|
 |
 |
 |
|
|
-
- BungleFeet

-
Total Posts: 11
Joined: 2008-08-20
|
bkmacdaddy - 30 June 2008 08:45 PM RPGShop - 21 June 2008 02:12 AM
I was wrong, I think the default is ASC… how do I change the default for Newest to be DESC? I see a function to getCurrentDirection() but not sure that’ll help. How do I set it to ‘desc’ to start with on each page?
Figured it out: in the same toolbar.php file, around lines 101-110, change this:
public function getCurrentDirection()
{
if ($dir = (string) $this->getRequest()->getParam($this->getDirectionVarName())) {
$dir = strtolower($dir);
if (in_array($dir, array(’desc’, ‘asc’))) {
return $dir;
}
}
return ‘asc’;
}
To this:
public function getCurrentDirection()
{
if ($dir = (string) $this->getRequest()->getParam($this->getDirectionVarName())) {
$dir = strtolower($dir);
if (in_array($dir, array(’desc’, ‘asc’))) {
return $dir;
}
}
return ‘desc’;
}
Along with your ‘newest’ entity_id it works like a charm!
I can offer a slight improvement to the above code. The most sensible default behaviour would be DESC when ordered by newest (giving newest first), but ASC when ordered by Name or Price (although you may prefer most expensive first, depending on the situation). To achieve this, edit the getCurrentDirection() function as below:
public function getCurrentDirection() { if ($dir = (string) $this->getRequest()->getParam($this->getDirectionVarName())) { $dir = strtolower($dir); if (in_array($dir, array('asc', 'desc'))) { return $dir; } } // CHANGE: This code causes the default order for Newest to be descending (newest first) if ($this->getCurrentOrder() == 'entity_id') { return 'desc'; } return 'asc'; }
Cheers,
Bungle
|
| |
|
 |
 |
 |
|
|
-
- yamushk

-
Total Posts: 3
Joined: 2008-08-12
|
Moshe - 25 October 2007 08:57 AM @macsmart: it’s not configurable from admin yet, take a look in app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php function getCurrentOrder() - it will take the first available. So you can either change this method or change available orders on line 41
Some stores, especially those dealing with design / artistic / aesthetic products would like to have the items listed by default according to how their pictures look (as default). The price, best value etc - are much less interesting.
Do you plan on adding a possibility to sort the products on the admin level (I want this product no. 1, this no. 2 etc) - and let me choose it by my will and not by “objective” data (price or name or date or random)?
Thank you - without it - the page looks messy and unatractive.
|
| |
|
 |
 |
 |
|
|
-
- LaneB

-
Total Posts: 4
Joined: 2008-11-06
Brisbane, Australia
|
Hi,
In the “Sort By:” box I want to remove the option of sorting by “Best Value”, as I’m not quite sure what that actually means. I like to think all my products are good value…
It looks like the method for doing this, by editing the toolbar.php file, has been well-explained in the preceding posts.
However, when I went to edit this file, I noticed it said:
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
Presumably, any edits you make to the toolbar.php file will be overwritten and lost every time you upgrade to a new version of Magento.
Is this correct? If so, is there any workaround for this, like having some control over the “Search By” options through the admin interface?
|
| |
|
 |
 |
 |
|
|
-
- BungleFeet

-
Total Posts: 11
Joined: 2008-08-20
|
LaneB - 06 November 2008 02:54 PM
Presumably, any edits you make to the toolbar.php file will be overwritten and lost every time you upgrade to a new version of Magento.
Is this correct? If so, is there any workaround for this, like having some control over the “Search By” options through the admin interface?
Yes, if you want upgrades to your Magento install to go smoothly, it is important not to edit any of the core files. Fortunately, it is possible to override the functionality of the core files in Magento. In your case, to modify Toolbar.php in order to remove the “Best Value” option, create a new file Toolbar.php in the directory app/code/local/MyCompany/Catalog/Block/Product/List. Put the following code in the file:
<?php class MyCompany_Catalog_Block_Product_List_Toolbar extends Mage_Catalog_Block_Product_List_Toolbar { protected function _construct() { parent::_construct(); $this->_availableOrder = array( /* BEST VALUE option removed */ 'name' => $this->__('Name'), 'price' => $this->__('Price') );
switch (Mage::getStoreConfig('catalog/frontend/list_mode')) { case 'grid': $this->_availableMode = array('grid' => $this->__('Grid')); break;
case 'list': $this->_availableMode = array('list' => $this->__('List')); break;
case 'grid-list': $this->_availableMode = array('grid' => $this->__('Grid'), 'list' => $this->__('List')); break;
case 'list-grid': $this->_availableMode = array('list' => $this->__('List'), 'grid' => $this->__('Grid')); break; } $this->setTemplate('catalog/product/list/toolbar.phtml'); } ?>
Now edit app/etc/local.xml, adding the following code inside the global tag:
<blocks> <catalog> <rewrite> <product_list_toolbar>MyCompany_Catalog_Block_Product_List_Toolbar</product_list_toolbar> </rewrite> </catalog> </blocks>
This will cause Magento to load your custom code, overriding the core functionality.
Cheers,
Bungle
|
| |
|
 |
 |
 |
|
|
-
- LaneB

-
Total Posts: 4
Joined: 2008-11-06
Brisbane, Australia
|
Thanks Bungle - that’s really helpful. I’ll give it a try.
|
| |
|
 |
 |
 |
|
|
-
- chatlumo

-
Total Posts: 88
Joined: 2008-02-20
Paris
|
BungleFeet - 07 November 2008 12:25 AM
Yes, if you want upgrades to your Magento install to go smoothly, it is important not to edit any of the core files. Fortunately, it is possible to override the functionality of the core files in Magento. In your case, to modify Toolbar.php in order to remove the “Best Value” option, create a new file Toolbar.php in the directory app/code/local/MyCompany/Catalog/Block/Product/List. Put the following code in the file:
I use this possibility to keep the Magento core cleen.
So, my store is in French but now, the Toolbar is shown in english, do you know why ?
Thanks.
|
| |
|
 |
 |
 |
|
|
-
- elfling

-
Total Posts: 20
Joined: 2008-10-21
|
Just been looking to see what I would need to do to sort by sub category.
I’ve tried
'category_ID' => $this->__('Category')
as well as
'category' => $this->__('Category') ,
but with no resolve.
Is it going to be painfully simple that i’ve just overlooked?
|
| |
|
 |
 |
 |
|
|
-
- magnet0

-
Total Posts: 26
Joined: 2007-10-23
Heraklion, Crete
|
So
If all we need to do, is change the default store ordering into “SKU” instead, where we have to do that?
- I do not need to change the drop down options. They are ok for me.
- And I do not want to add the product sku as a new option value there (I know it is working. I checked out allready).
Please help
Yiannis
|
| |
|
 |
 |
 |
|
|