Hi all,
I created a custom attribute for products called: Sellerid
This can be shown on the product page by adding this code to view.phtml:
echo $_product->getSellerid() ;
How can I change this to a link that shows all products with the same Sellerid?
With the label: 'show all'.
I'm using magento CE 1.9.1 with the default RWD theme.
This can probably be done by creating a custom module, but I've never done that before.
I'd rather just put a couple of lines of code in the view.phtml of my template.
Thanks!
Solved! Go to Solution.
Hi Kuafasoft,
based on your last post I did some more searching and found a similar query on stackoverflow.
I tweaked your solution a bit and got a working query in a URL now!
Here is my final working code for anyone who needs it:
<a href="<?php echo $this->getUrl('catalogsearch/advanced/result', array('_query'=>'sellerid='.$_product->getSellerid()));?>"><?php echo $this->__('Show All');?></a>
Not sure if I should mark my own reply as a solution, but I'll do it anyway!
Basically it seems that you want to show products of same seller into product view page. Do filter by seller Id into respected page.
$productCollection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToFilter('sellecr_id', <seller_id>)
All the best
HI Grav,
thanks for the effort! I tried to play around with your solution, but can't seem to get any results.
Actually I would like to have a link 'show all products' instead of showing the products itself on a product page.
(Basically an advanced catalog search result on a page)
But this could be good start! I removed the brackets at the end, because it caused an error + added an echo.:
Here is my current piece of code:
echo " <br>E-mail: "; echo $_product->getEmail() ; echo "<br>Seller ID: "; echo $_product->getSellerid() ; echo "<br>All products:"; echo $productCollection = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('sellerid', sellerid);
Any help is much appreciated!
you can simply mark this attribute used in advanced searching with attribute manager, then add an advancedsearch link with parameters in that template
<a href="<?php echo $this->getUrl('catalogsearch/advanced/result', array('seller_id', $_product->getSellerId()));?>"><?php echo $this->__('Show All');?></a>
Hi Kuafasoft,
thanks for the code.
I tried it and I'm almost there.
First I had to change your code by removing an '_' and 'capital 'i' from the sellerid.
Now on my product page it shows the text 'Show all' and when I hover it with the mouse I see the URL
https://www.mydomainname.nl/catalogsearch/advanced/result/0/Sellerid/1/1001/
As you can see it does retrieve the sellerid, which is 1001 in this case.
But when I click it I end up at: https://www.mydomainname.nl/catalogsearch/advanced/
, which of course had nothing filled out in the form and no search results.
A manual working url would be like this:
https://www.mydomainname.nl/catalogsearch/advanced/result/?sellerid=1001
I don't know how to fix this last bit unfortunately.
Current code:
<a href="<?php echo $this->getUrl('catalogsearch/advanced/result', array('Sellerid', $_product->getSellerid()));?>"><?php echo $this->__('Show All');?></a>
oops, should be like this
<a href="<?php echo $this->getUrl('catalogsearch/advanced/result', array('sellerid' => $_product->getSellerid()));?>"><?php echo $this->__('Show All');?></a>
and you shouldn't have to capitalize 's' in seller id
HI,
thanks a lot for taking the time to help!
I tried your updated code and get a new url when I hover it:
https://www.mydomainname.nl/catalogsearch/advanced/result/sellerid/1001/
So it still retrieves the ID, but when i click it I end up at the same standard advanced search page/url.
It does have a clear message this time: please specify at least one search term.
Hi Kuafasoft,
based on your last post I did some more searching and found a similar query on stackoverflow.
I tweaked your solution a bit and got a working query in a URL now!
Here is my final working code for anyone who needs it:
<a href="<?php echo $this->getUrl('catalogsearch/advanced/result', array('_query'=>'sellerid='.$_product->getSellerid()));?>"><?php echo $this->__('Show All');?></a>
Not sure if I should mark my own reply as a solution, but I'll do it anyway!