InDaMixXx
Total Posts: 77
Joined: 2008-04-29
Indeed, because a list of products with only their images is not really usefull
Anyone ? =)
InDaMixXx
Total Posts: 77
Joined: 2008-04-29
Bump ?
Posted: August 10 2008
| top
| # 47
russell2pi
Total Posts: 25
Joined: 2008-07-19
Logically, from the above, you should be able to get it to work in search results by editing catalogsearch.xml, changing
< block type = "catalog/product_list" name = "search_result_list" template = "catalog/product/list.phtml" ></ block >
to (for example)
< block type = "catalog/product_list" name = "search_result_list" template = "catalog/product/list.phtml" > < action method = "addAttribute" >< attribute > author </ attribute ></ action > < action method = "addAttribute" >< attribute > byline </ attribute ></ action > </ block >
However, this does not work. The search results code now dies with the following error:
Fatal error: Call to a member function getProductCollection() on a non-object in /home/huntingb/public_html/app/code/core/Mage/Catalog/Model/Layer.php on line 41
I don’t even understand why it is getting into Layer.php for search results.
Anyone????
Posted: August 13 2008
| top
| # 48
russell2pi
Total Posts: 25
Joined: 2008-07-19
Ok, got it!! product_list doesn’t have it’s collection set until after it is declared. The following code works:
< block type = "catalog/product_list" name = "search_result_list" template = "catalog/product/list.phtml" ></ block > < action method = "setListOrders" /> < action method = "setListModes" /> < action method = "setListCollection" /> < reference name = "search_result_list" > < action method = "addAttribute" >< attribute > author </ attribute ></ action > < action method = "addAttribute" >< attribute > byline </ attribute ></ action > </ reference >
You need to do it both in the standard and advanced section. (Just search for list.phtml in catalogsearch.xml, it’s there twice.)
Posted: August 13 2008
| top
| # 49
InDaMixXx
Total Posts: 77
Joined: 2008-04-29
And it works ? I thought it was this, but it is so simple.... It is the same thing if we want attributes in the product list
Question… Why this is not like that “by default” ?
Posted: August 13 2008
| top
| # 50
seudo?
Total Posts: 152
Joined: 2008-04-21
@russell2pi - Thank you so much for the search result attribute code. That works great!!!
Also got drop down attributes to work using this:
<?php echo $_product -> getAttributeText ( 'drop_down_attribute_name_here' ) ?>
Signature
- Magento ver. 1.1.6
Posted: August 23 2008
| top
| # 51
Hugoto
Total Posts: 23
Joined: 2008-08-11
Moshe - 22 November 2007 01:17 AM
@spider: if you want to add custom attributes to product listing, you will have to add them in the layout xml.
To save time we do not load all the available attributes for all product in the list, only necessary ones (name, image, url_key, etc.)
Edit main.xml, find handles <catalog_category_default> and <catalog_category_layered> and replace in both:
< block type = "catalog/product_list" name = "product_list" ></ block >
with:
< block type = "catalog/product_list" name = "product_list" > < action method = "addAttribute" >< code > promotion </ code ></ action > </ block >
You will need to repeat <action> tag for each additional attribute you wish to see in product list.
Posted: August 25 2008
| top
| # 52
Albert van der Veen
Total Posts: 8
Joined: 2008-05-30
Amsterdam
@russell2pi
russell2pi - 13 August 2008 02:51 AM
Ok, got it!! product_list doesn’t have it’s collection set until after it is declared. The following code works:
Brilliant! Thanks a lot for this one. Question has been asked in quite a few other threads. Will post a link to your solution there.
grtz,
Albert
Posted: August 26 2008
| top
| # 53
Hugoto
Total Posts: 23
Joined: 2008-08-11
russell2pi - 13 August 2008 02:51 AM
Ok, got it!! product_list doesn’t have it’s collection set until after it is declared. The following code works:
< block type = "catalog/product_list" name = "search_result_list" template = "catalog/product/list.phtml" ></ block > < action method = "setListOrders" /> < action method = "setListModes" /> < action method = "setListCollection" /> < reference name = "search_result_list" > < action method = "addAttribute" >< attribute > author </ attribute ></ action > < action method = "addAttribute" >< attribute > byline </ attribute ></ action > </ reference >
You need to do it both in the standard and advanced section. (Just search for list.phtml in catalogsearch.xml, it’s there twice.)
Thank you very much, that works!!!
Posted: August 26 2008
| top
| # 54
Hugoto
Total Posts: 23
Joined: 2008-08-11
russell2pi - 13 August 2008 02:51 AM
Ok, got it!! product_list doesn’t have it’s collection set until after it is declared. The following code works:
< block type = "catalog/product_list" name = "search_result_list" template = "catalog/product/list.phtml" ></ block > < action method = "setListOrders" /> < action method = "setListModes" /> < action method = "setListCollection" /> < reference name = "search_result_list" > < action method = "addAttribute" >< attribute > author </ attribute ></ action > < action method = "addAttribute" >< attribute > byline </ attribute ></ action > </ reference >
You need to do it both in the standard and advanced section. (Just search for list.phtml in catalogsearch.xml, it’s there twice.)
Thank you very much, that works!!!
Posted: August 26 2008
| top
| # 55
LindyKyaw
Total Posts: 31
Joined: 2008-01-02
product list collection and search collection use different collections.
You need to select the same attributes between search collection and product list collection.
simple search list collection is located in Mage_CatalogSearch_Block_Result
protected function _getProductCollection ()
advanced search list collection is located in Mage_CatalogSearch_Model_Advanced
public function getProductCollection ()
Both of the search collection select attributes from Mage/Catalog/etc/config.xml
< product > < collection > < attributes >
Product list collection is located in Mage_Catalog_Model_Layer
public function prepareProductCollection
Posted: August 27 2008
| top
| # 56
btbc
Total Posts: 86
Joined: 2008-06-11
I’m going to spend a while reviewing all the posts, but am I correct in thinking that this will allow me to list the manufacturers in a list format on the main page?
Example: Manufacturer attribute
Posted: September 4 2008
| top
| # 57
FabioP
Total Posts: 20
Joined: 2008-06-23
Gabriel Queiroz - 16 July 2008 07:31 PM
Hi,
Thanks for answering.
Yes, I’m adding it to the home page in CMS. Unfortunatelly, it didn’t work… I’ve changed your code a little, using code instead of attribute, but no luck… here’s the final code…
{{block type = "catalog/product_list" name = "product_list" template = "catalog/product/list.phtml" category_id = "4" }} {{action method = "addAttribute" }}{{code}}manufacturer{{ / code}}{{ / action}} {{ / block}}
I’ll keep on trying, will post it here if I sort something out…
Thanks!
Did someone figured this one out? How to display additional attributes on a CMS page?
Using the code above doesn´t work because for some reason the bit after
{{block type = "catalog/product_list" name = "product_list" template = "catalog/product/list.phtml" category_id = "4" }}
gets displayed on the page as regular text instead of being passed on as code.
And if you input that in the Custom XML field, you generate an error.
Posted: September 5 2008
| top
| # 58
FabioP
Total Posts: 20
Joined: 2008-06-23
I already search the forum for this answer but could not find one.
If anyone know how to solve the issue I posted on the post above this one, please answer it or post the link to a thread where someone have the answer.
Thank you.
Posted: September 10 2008
| top
| # 59
jrutter
Total Posts: 23
Joined: 2008-04-08
will_h - 31 July 2008 08:00 PM
Moshe - 06 May 2008 10:12 PM
Looks like it was changed. Please try this:
<?php echo $_product -> getResource ()-> getAttribute ( 'my_weight' )-> getFrontend ()-> getValue ( $_product ) ?>
This worked perfectly, added to view.phtml v1.1.1 - Thank you
[EDIT]
This is my final code for displaying my attribute on the product view page. This also makes the text clickable with the URL entered in the attribute field. Also set new classes for the divs.
<?php if ( $_product -> getResource ()-> getAttribute ( 'Attribute_Code' )-> getFrontend ()-> getValue ( $_product )): ?> < div class= "downloads" > < div class= "head" > < h4 > Product Downloads </ h4 > </ div > < a href = "<?php echo $_product->getResource()->getAttribute('Attribute_Code')->getFrontend()->getValue($_product) ?>" target = "_blank" > <?php echo $_product -> getResource ()-> getAttribute ( 'Attribute_Code' )-> getFrontend ()-> getLabel ( $_product ) ?> </ a > </ div > <?php endif; ?>
Hope this helps someone in the future.
- Will
This definitely helped me, thanks so much Will! Great Stuff
Jake
Posted: September 14 2008
| top
| # 60