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

xtech 04-28-2011 12:25 AM

Re: Filter by Brand and Sort by
 
Hi am2003,
I cannot able to call brand name(in dropdown) with this code in my 4.4.2 version.Is it possible to display linked brand in a menu instead of drop down?

Have there any problem with this code in 4.4.2?

xtech 05-06-2011 10:10 AM

Re: Filter by Brand and Sort by
 
Any solution regarding my issue?

Learner 05-10-2011 04:54 AM

Re: Filter by Brand and Sort by
 
Hi am2003,

Any solution of calling manufacturer name??

Anyone in the forum please !!!!

Rajdeep 05-11-2011 08:59 PM

Re: Filter by Brand and Sort by
 
am2003,
thanks for your code but will not work on x cart latest version.I cannot able to see manufacturer name in the drop down.

What is the problem?

Learner 05-17-2011 11:14 PM

Re: Filter by Brand and Sort by
 
Hi am,
Any solution to call manufacturer name in drop down page?? Currently it is showing white but id is calling.How to call name in 4.4.2??

Have there any solution??

Wait for your reply..
Thanks a lot.

ADDISON 05-18-2011 05:05 AM

Re: Filter by Brand and Sort by
 
Sorry Guys. I don't have time to finish the issues. For sure I will come back with full support on this feature. Who knows, maybe QT will see that Zen Cart has by default "filter by manufacturer" in a category and they will offer this feature for free in the next v4.4.4.

cherie 05-19-2011 12:54 PM

Re: Filter by Brand and Sort by
 
Quote:

Originally Posted by am2003
Who knows, maybe QT will see that Zen Cart has by default "filter by manufacturer" in a category and they will offer this feature for free in the next v4.4.4.

:lol:

Learner 05-29-2011 11:44 PM

Re: Filter by Brand and Sort by
 
Hi am2003,

Ok I am waiting for your support to get it done for the latest x cart version.

Thank you.

xtech 06-01-2011 03:09 AM

Re: Filter by Brand and Sort by
 
Hi am2003,

How to resolve this blank page issue in dropdown for latest??

Can you help me?

ADDISON 06-01-2011 03:49 AM

Re: Filter by Brand and Sort by
 
That blank means no manufacturer. You can fill that blank space with a text like no manufacturer, using an {if}{/if}. I will come back to this customization when I will get more time for it.

xtech 06-01-2011 04:21 AM

Re: Filter by Brand and Sort by
 
Hello,
The name of the manufacturers is not showing in dropown.Then why I called no manufacturer??

In the filter id is calling but name is not coming why??

When I expect your support fully for this . Actually i want to launch a site next couple of week with this features done by you.

It is fine.I just want to call manufactures name that's all.

Can you help me?

Thanks a lot.

ADDISON 06-01-2011 04:42 AM

Re: Filter by Brand and Sort by
 
Some products are having a manufacturer associated, others not.

I am sorry I cannot offer you fully support right now. I don't make any custom work, even for money. As I said before, I will come back to this feature once the time will allow me. It is a must have feature, requested many years in the past.

xtech 06-01-2011 04:48 AM

Re: Filter by Brand and Sort by
 
Hello,
When I expect your support??I will wait for your support.

Thanks again.


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

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