Magento category order on frontend - magento

I want to change the default order of categories in Magento frontend navigation to order by name. Running Magento 1.5.
Does anyone have a clue?

You can manually order the categories in admin by dragging them up and down in the left pane of "Manage Categories" page.

We have been searching on a way to do this also, and ended up doing this:
<?php
...
$categories = array(1,3,5); // this holds the category ids you want to show, in the correct order
foreach($categories as $cat){
Mage::getModel("catazlog/category")->load($cat);
// Do whatever you want here
}
?>
It definitely isn't the cleanest way to achieve what you are trying to do, but just offering you a quick (dirty?) solution.
-Kenny

You would need to build the collection first, then sort the attribute
Mage::getModel('catalog/category')->getCollection()->addFieldToFilter('parent_id', '319')->addAttributeToSort('name', 'ASC');

In Admin Panel go to Catalog—>Manage Categories.
From there you can change categories order by just drag-and-dropping categories right in category tree at the left-hand side of the page.
Good luck!!!

Related

How to retrieve the chosen order attribute on category page in magento?

Been googling for a while now, but couldn't find a solution for this - i think - kinda trivial question. I'd like to retrieve the attribute by which a product catalog is ordered. I don't want to be able to order the category page by a custom attribute, just want to now by which attribute it is sorted.
Actually I have three possibilities "position", "name" & "price. I would like to do something with the first 3 products, but only if the category catalog is ordered by position.
Anyone have an idea how I can achieve this value?
Thanks!
<?php
echo Mage::getBlockSingleton('catalog/product_list_toolbar')->getCurrentOrder();
?>

Magento custom Product Attribute

I add an attribute type Yes/No is_special to product.
(I want to just logged user can see special products.)
Then, I open some products and set to Yes But when I show it on front end, All is No.
I clear cache and reindex before. But It still No
Please help me guys. I am very grateful to You...!!
Thanks In Advance...!!
When attributes are added, they are added to the database and magento caches the calls to certain databases. Try deleting your cache folder in var/cache and see if that helps.
When you create a new product attribute, you have a lot of options, a few changing the loading bahavious "Show in product listing" sets the collection to load this on the category pages, "Visible on Product View Page on Front-end" loads the attribute on the product view page.
First you need to add featured/special product attribute to magento. Please refer my tutorial which explains how to add yes/no attribute.
http://www.pearlbells.co.uk/adding-custom-product-attributes-in-magento/
Then you filter the featured products using the code in phtml.
<?php
$featuredProducts = Mage::getModel('catalog/category')->load($category_id)
->getProductCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('featured_product', 1)
->addAttributeToFilter('status', 1);
?>

Magento - Some products not for sale

I would like to set some products to "non-saleable", removing the "Add to cart" button and adding a link to contact form.
I'm looking for this solution for a few weeks. Searching, I found this post:
Magento - product that are not for sale
At the end of page have this answer:
""Alternatively, you could set up a new product attribute that replaces the add to cart button with something different (more info button, popup, etc)."
How can I do it?
Another post about this subject:
http://www.e-commercewebdesign.co.uk/blog/magento-tutorials/non-salable-products-with-attribute-sets.php
But I can't make it work. Someone could help me with more details?
small tutorial
Create a new attribute "saleable"
Default Value = yes
Unique value = no
values required = yes
apply to = all product types
use in quick search = no
use in advanced searched = no
comparable on front-end = no
Use In Layered Navigation = no
Use for Promo Rule Conditions = no
Visible on Product View Page on Front-end = no
Used in Product Listing = no
Used for Sorting in Product Listing = no
Manage titles
admin = "Is saleable"
Default store view = "Is saleable"
Now add it to your attribute set (default)
create a product or edit a product and define the is "is saleable" attribute.
Now go to the view of your product
/tomcollins.be/app/design/frontend/default//template/catalog/product/view.phtml
put an if statement like this
<? if($_product->getData('saleable')): ?>
// do what ever you want
<?php else: ?>
// do what ever you want
<?php endif; ?>
Hope this helps someone :)
bye
Modify your product with an Attribute for example nonsaleable. If that Attribute has value true the product is not saleable.
So now you should take a look at the
Productview in app/design/frontend/your_theme/your_theme/template/catalog/product/view.phtml
and the
listview app/design/frontend/your_theme/your_theme/template/catalog/product/list.phtml
Now look where in these files are the addtocart buttons are located.
Before this button you place an if nonsable === TRUE { make something } else { addtocart }
Thats the way i would try this.
Sorry for my bad english. I'm still tired :))))
For all non-for sale products you can set a quantity to 0. It will automatically remove Add to cart. Then you can add link to contact form on all products where add-to-cart doesn't exist. I am coming from Magento Go background so I would do it this way, but I know that with community and enterprise versions you have more flexibility.
I guess you will get your desire requirement through this extension because the developer teams for this extension is really very supportive.Please refer below link for extension:
Click here to get extension

Magento: How to sort product collection?

i have created a list_home.phtml that i call from {{block type="catalog/product_list" category_id="6" template="catalog/product/list_home.phtml"}}The category is very important because i will have 3 tabs in this homepage slider.This is a version of the product list without toolbar to include in a homepage slider, where the user should never be able to change the sorting.
However in the main catalog there is the toolbar. Currently, if the user changes the sorting there and then goes back to the homepage the sort order on the home page will also be affected!
How can i force the $collection to always sort by newest and also filter the category from the frontend's block call?
I am really almost stuck after opening around 50 tabs in the broswer and trying to research, really need some help here please.
Thanks in advance.
On the product collection you can set the order by calling ->setOrder on it.
I'm not sure of the field you would need to order by, but if you wanted to set it by price ascending you would do
->setOrder('price', 'ASC');
To filter the category you need to do this
$productCollection = Mage::getModel('catalog/category')->load($categoryId);
You can then set the sort order

How to change the product display order in magento

How can I change the product display order in the front end (grid or list) by setting some preferences from back-end? I guess it should be other than best value and name from the default Magento display order property.
I tried by creating a new attribute called display_order, and each product holds a value based on its value the product needs to shown in front end. However, it is not working. Please help me fix this.
You'll need to extend the Mage_Catalog_Block_Product_List block to provide your own functionality for the getProductCollection() method. Probably something along the lines of:
class ... extends Mage_Catalog_Block_Product_List {
function getProductCollection() {
parent::getProductCollection()->addAttributeToSort('display_order', 'ASC')
}
}
Then, of course, you'll have to update you layout xml file on your, presumably, custom controller (unless you want all of the product listing screens to act like this) to use your new block instead of the Magento default of catalog/product_list.
Why don't you use the Magento sorting thing ?
In your category, under Category Product you have the possibility to choose the sorting order in the last column. To do it through php, just make a custom script that you'll need to launch once.
$collection = 'Your product collection';
$result = array();
foreach ($collection as $product) {
$sort = 'Your way of calculating the desired sorting';
$result[$product->getId()]=$sort;
}
Mage::getModel('catalog/category')->load('your category id')->setPostedProducts($result)->save();
And that's it :)
To change the display order , first you need to set the default sort by option to position.This can be done from the magento admin configuration.After that you need to set position for all the products starting with the value 1.
I come across the following module which will make this task very easy, just by drag and drop the products from the manage categories itself.Please check the following extension
http://www.blackqubers.com/extensions/product-sorting-drag-and-drop.html
Hope this will helps you

Resources