X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Filter by Brand and Sort by (https://forum.x-cart.com/showthread.php?t=58437)

ADDISON 03-12-2011 12:39 PM

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:"&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?

ADDISON 03-15-2011 04:10 AM

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;


Learner 03-27-2011 10:36 PM

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.

Learner 03-28-2011 04:45 AM

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...

ADDISON 03-28-2011 04:57 AM

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.

Learner 03-28-2011 05:01 AM

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??

ADDISON 03-28-2011 05:15 AM

Re: Filter by Brand and Sort by
 
For the moment I cannot. I still learning as your name.

Learner 04-25-2011 03:07 AM

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?

Learner 04-25-2011 05:02 AM

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>

xtech 04-26-2011 09:46 AM

Re: Filter by Brand and Sort by
 
How to call brands one after another instead of drop down??


All times are GMT -8. The time now is 07:40 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.