View Single Post
  #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