Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Filter by Brand and Sort by

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-12-2011, 12:39 PM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Filter by Brand and Sort by

Hi folks,

This is my custom modification to get in products list Filter by Brand and Sort by.

skin -> customer -> search_sort_by.tpl

Code:
{* $Id: search_sort_by.tpl,v 1.2 2010/06/21 13:19:49 joy Exp $ vim: set ts=2 sw=2 sts=2 et: *} {if $sort_fields and ($url or $navigation_script)} {if $url eq '' and $navigation_script ne ''} {assign var="url" value=$navigation_script} {/if} {if $navigation_page gt 1} {assign var="url" value=$url|amp|cat:"&amp;page=`$navigation_page`"} {else} {assign var="url" value=$url|amp} {/if} <div class="search-sort-bar no-print"> <form name="filter_manufacturer" id="filter_manufacturer" style="margin: 0px; padding-right: 10px;"> <select name="filter_manufacturer_select" onchange="MM_jumpMenu('parent',this,0)" id="manspan"> <option value="">Filter by Brand</option> {section name=man loop=$found_manu} <option value="{$url}&amp;manufacturerid={$found_manu[man].manufacturerid}" {if $found_manu[man].manufacturerid eq $manufacturerid} selected="selected"{/if}>{$found_manu[man].manufacturer}</option> {/section} <option value="{$url}">All Brands</option> </select> <select name="sort_field" onchange="MM_jumpMenu('parent',this,0)"> <option value="">Sort by</option> {foreach from=$sort_fields key=name item=field} <option {if $name eq $selected and $direction eq 0}selected{/if} value="{$url}sort={$name}&sort_direction=0&amp;manufacturerid={$manufacturerid}">{$field} (Ascending)</option> <option {if $name eq $selected and $direction eq 1}selected{/if} value="{$url}sort={$name}&sort_direction=1&amp;manufacturerid={$manufacturerid}">{$field} (Descending)</option> {/foreach} </select> </form> </div> {/if}

skin -> customer -> home.tpl in <head></head>

Code:
{literal} <script> function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } </script> {/literal}


Of course the code can be improved using labels, options in Appearance.

It's working fine except 2 issues I get.

1) How can I keep always the order of brands in drop down list, no mater what option I select in Sort by list? For Default options it is working fine.

2) When no Brand, in Filter by Brand list there is an empty option at the end. How can I get rid off it?
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #2  
Old 03-15-2011, 04:10 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Re: Filter by Brand and Sort by

x-cart root -> products.php

AFTER

Code:
// Basic X-cart search of products in category. because if you selected a manufacturer in a category, without this you would only see 1 manufacturer in the drop down box. $search_data["products"] = array(); $search_data["products"]["categoryid"] = $cat; $search_data["products"]["search_in_subcategories"] = ""; $search_data["products"]["category_main"] = "Y"; $search_data["products"]["category_extra"] = "Y"; $search_data["products"]["forsale"] = "Y"; $mode = "search"; include $xcart_dir."/include/search.php"; $search_data["products"] = $old_search_data; $mode = $old_mode;

ADD

Code:
/ If Xcart found some products, loop through all the manufacturers it found and add it to an array... if($products) { $advanced_manufacture = array(); $tmp = array(); foreach($products as $key=>$value) { // maybe try unique ?... if(!in_array($value["manufacturerid"], $tmp)) { $advanced_manufacture[] = array("manufacturer"=>$value['manufacturer'], "manufacturerid"=>$value['manufacturerid']); $tmp[] = $value["manufacturerid"]; } } } // assign to smarty $smarty->assign("found_manu",$advanced_manufacture); $smarty->assign("manufacturerid",$manufacturerid); //unset search_data... unset($search_data); // NOW research the data but include the manufacturer ID if it found one $old_search_data = $search_data["products"]; $old_mode = $mode; $search_data["products"] = array(); $search_data["products"]["categoryid"] = $cat; // here is where we search for the manufacturer if ($manufacturerid) $search_data["products"]["manufacturers"] = array($manufacturerid); $search_data["products"]["search_in_subcategories"] = ""; $search_data["products"]["category_main"] = "Y"; $search_data["products"]["category_extra"] = "Y"; $search_data["products"]["forsale"] = "Y"; $mode = "search"; include $xcart_dir."/include/search.php"; $search_data["products"] = $old_search_data; $mode = $old_mode;
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #3  
Old 03-27-2011, 10:36 PM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Filter by Brand and Sort by

I want to display the manufacturer's/brand's name/logo which are currently on that category.I have approximately 50 manufactures/brand in my store.Each manufacturer links with different different category.Suppose X category links with a,b,c,d manufacturer's product among 50 manufacturers.I want to display only a,b,c,d manufacturer's name/logo when I click on X category.[NOT IN DROPDOWN BUT DISPLAY HORIZONTALLY]

Is it possible? Can you help me?

Thanks.
__________________
4.6.1 Platinum


Reply With Quote
  #4  
Old 03-28-2011, 04:45 AM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Filter by Brand and Sort by

Hi am2003,
I cannot able manufacturer name in the drop down in my 4.4.2 version only showing me white without any name.How to resolve it??

Also if I want to call all filtered manufacturer in a tpl which only see brand instead of dropdown select box in the category page. How to call.

It is an excellent work done by you.Kindly help me to do that..

Thanks...
__________________
4.6.1 Platinum


Reply With Quote
  #5  
Old 03-28-2011, 04:57 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Re: Filter by Brand and Sort by

Do you have manufacturers associated with your products listed in a category?

Please see I have 2 issues. One issue is what you got. I wanted to bring in front one of the most requested features, you can see in other free shopping cart.

For sure I will correct them pretty soon. Help from your side in much appreciated.
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #6  
Old 03-28-2011, 05:01 AM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Filter by Brand and Sort by

Quote:
Originally Posted by am2003
Do you have manufacturers associated with your products listed in a category?

Please see I have 2 issues. One issue is what you got. I wanted to bring in front one of the most requested features, you can see in other free shopping cart.

For sure I will correct them pretty soon. Help from your side in much appreciated.

Yes, am 2003 thanks for your reply.
I just want to display only that manufacturers name which is linked with category only on the category page in manufacturer page [that is in contextual form].How to achieve that??

Can you help me??
__________________
4.6.1 Platinum


Reply With Quote
  #7  
Old 03-28-2011, 05:15 AM
  ADDISON's Avatar 
ADDISON ADDISON is offline
 

X-Man
  
Join Date: Jan 2008
Posts: 2,613
 

Default Re: Filter by Brand and Sort by

For the moment I cannot. I still learning as your name.
__________________
X-Cart Next: Business 5.2 (learning and testing)
X-Cart Classic: Gold and Gold Plus 4.7
Lots of Modules and Customizations
OS in use: Red Hat Enterprise, Fedora, CentOS, Debian, Ubuntu, Linux Mint, Kali Linux
Ideas for Server configuration (basicaly): Nginx/Pound (reverse proxy), Apache/Nginx (webserver), Squid/Varnish (cache server), HHVM or (PHP-FPM + PHP 5.6 + opcache), MariaDB/Percona MySQL Server, Redis (storing sessions)

You can catch my ideas here: http://ideas.x-cart.com
Reply With Quote
  #8  
Old 04-25-2011, 03:07 AM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Filter by Brand and Sort by

Hi am 2003,
Is it possible to display in a menu or dialog (all linked manufacturer in a list) rather than drop down ??

If possible how?
__________________
4.6.1 Platinum


Reply With Quote
  #9  
Old 04-25-2011, 05:02 AM
 
Learner Learner is offline
 

X-Adept
  
Join Date: Dec 2008
Posts: 807
 

Default Re: Filter by Brand and Sort by

Hi am 2003,
Have you seen if you put manufacturerid in place of manufacturer then id is tracking.

Here is the code-

<option value="{$url}&amp;manufacturerid={$found_manu[man].manufacturerid}" {if $found_manu[man].manufacturerid eq $manufacturerid} selected="selected"{/if}>{$found_manu[man].manufacturerid}</option>
__________________
4.6.1 Platinum


Reply With Quote
  #10  
Old 04-26-2011, 09:46 AM
 
xtech xtech is offline
 

X-Adept
  
Join Date: Jun 2010
Posts: 605
 

Default Re: Filter by Brand and Sort by

How to call brands one after another instead of drop down??
__________________
X-cart Platinum
4.6.1
Reboot template
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:59 PM.

   

 
X-Cart forums © 2001-2020