Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Product Attribute Filter (A Holy Grail?) Convert 2.2 to 2.3 - Need Help On Box


RMD27

Recommended Posts

So I found a contribution that filters by attribute. I have been looking for months, I do not know how I did not find it sooner

 

Its here >> http://addons.oscommerce.com/info/5997

 

It looks stunning in its simplicity, power and ease of installation

 

The problem is I am trying to install it onto a 2.3 version of OSC and the info boxes are completely different

 

I go to modules > boxes > install and I see the module there in all its tantilising glory with the dropdowns but with no way to install it. 

 

Would someone mind putting this together for the community o:) ?

 

If this works like I hope it will this could be an essential contribution to any shop ie a contribution that takes about 5 minutes to install and allows you to filter products by attribute. 

 

Here is the infobox from the contribution (There is also an issue with the advanced search result page but small potatoes compared to this)

<?php 
 
//return the setting options

// consists of: Shape 5, Type 1, Size 6, Material 7
//if a value has been selected, it will show as selected.

$opts = array( 6 => 'Car', 9 => 'Engine', 8 => 'Part Type');

// the number before the word represents the option ID in the `product_options` table
// the word after contains the displayed name of the dropdown box, which would usually be the same as the name

//title of the box

$heading = 'attribute selector';

// you should not need to edit below this line 
//------------------------

$mainhtml = ""; //the var to hold all of the html

foreach ( $opts as $opt => $name) {
	
	unset($html);
	
	$html = "<tr><td width='125px'>
				$name 
			</td></tr>
			<tr><td>
			<SELECT name='$opt' onchange='document.m_srch.submit();'>
			<OPTION value='not'>---</OPTION>";//print the name of the box and start the drop down
	
	$sql = "SELECT `products_options_values_id` from `products_options_values_to_products_options` WHERE `products_options_id`='$opt'"; 
	$res = tep_db_query($sql);// get the values of all the options for that catagory
	while($id = tep_db_fetch_array($res)){
	
		$optnamear = tep_db_query("SELECT `products_options_values_name` from `products_options_values` WHERE `products_options_values_id`='$id[products_options_values_id]'");
		
		$optname = tep_db_fetch_array($optnamear);
		
		//create the dropdown
		
		$html .= "<OPTION value='$id[products_options_values_id]' ";
		
		if($_GET[$opt] == $id['products_options_values_id']){
			$html .= "selected='selected'"; // if the product has already been selected keep it selected!
			} 
		
		$html .= ">$optname[products_options_values_name]</OPTION>";
		
		
		}
		
		$mainhtml .= $html."</SELECT></td></tr>";
		
		
	
	} 


echo "<tr><td>
<table border='0' width='100%' cellspacing='0' cellpadding='0'>
  <tr>
    <td height='14' class='infoBoxHeading'><img src='images/infobox/corner_left.gif' border='0' alt='' width='11' height='14'></td>
    <td  width='100%' height='14' class='infoBoxHeading'>$heading</td>
	</tr>
	</table>
	<table border='0' width='100%' cellspacing='0' cellpadding='1' class='infoBox'>
			<tr><td>
			<table class='infoBoxContents'>
			<FORM name='m_srch' action='advanced_search_result.php' method='get'>
			<INPUT type='hidden' value='1' name='m_op'> <INPUT type='hidden' value='1' name='keywords'> \n
			$mainhtml
			</table>
			</td></tr>
			</FORM>
		</table>
	</td></tr>";  


?> 

and here is the information box from 2.3

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  class bm_information {
    var $code = 'bm_information';
    var $group = 'boxes';
    var $title;
    var $description;
    var $sort_order;
    var $enabled = false;

    function bm_information() {
      $this->title = MODULE_BOXES_INFORMATION_TITLE;
      $this->description = MODULE_BOXES_INFORMATION_DESCRIPTION;

      if ( defined('MODULE_BOXES_INFORMATION_STATUS') ) {
        $this->sort_order = MODULE_BOXES_INFORMATION_SORT_ORDER;
        $this->enabled = (MODULE_BOXES_INFORMATION_STATUS == 'True');

        $this->group = ((MODULE_BOXES_INFORMATION_CONTENT_PLACEMENT == 'Left Column') ? 'boxes_column_left' : 'boxes_column_right');
      }
    }

    function execute() {
      global $oscTemplate;

      $data = '<div class="ui-widget infoBoxContainer">' .
              '  <div class="ui-widget-header infoBoxHeading">' . MODULE_BOXES_INFORMATION_BOX_TITLE . '</div>' .
              '  <div class="ui-widget-content infoBoxContents">' .
              '    <a href="' . tep_href_link(FILENAME_SHIPPING) . '">' . MODULE_BOXES_INFORMATION_BOX_SHIPPING . '</a><br />' .
              '    <a href="' . tep_href_link(FILENAME_PRIVACY) . '">' . MODULE_BOXES_INFORMATION_BOX_PRIVACY . '</a><br />' .
              '    <a href="' . tep_href_link(FILENAME_CONDITIONS) . '">' . MODULE_BOXES_INFORMATION_BOX_CONDITIONS . '</a><br />' .
              '    <a href="' . tep_href_link(FILENAME_CONTACT_US) . '">' . MODULE_BOXES_INFORMATION_BOX_CONTACT . '</a>' .
              '  </div>' .
              '</div>';

      $oscTemplate->addBlock($data, $this->group);
    }

    function isEnabled() {
      return $this->enabled;
    }

    function check() {
      return defined('MODULE_BOXES_INFORMATION_STATUS');
    }

    function install() {
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Information Module', 'MODULE_BOXES_INFORMATION_STATUS', 'True', 'Do you want to add the module to your shop?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Content Placement', 'MODULE_BOXES_INFORMATION_CONTENT_PLACEMENT', 'Left Column', 'Should the module be loaded in the left or right column?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\'), ', now())");
      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_BOXES_INFORMATION_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
    }

    function remove() {
      tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array('MODULE_BOXES_INFORMATION_STATUS', 'MODULE_BOXES_INFORMATION_CONTENT_PLACEMENT', 'MODULE_BOXES_INFORMATION_SORT_ORDER');
    }
  }
?>

Link to comment
Share on other sites

so i pasted the box code into the advanced search result page. better solution than a box anyway i think.

 

Next issue.

 

How do I make this query sort by products_options_values_name rather than randomly??

 

$optnamear = tep_db_query("SELECT `products_options_values_name` from `products_options_values` WHERE `products_options_values_id`='$id[products_options_values_id]' ") ;
Link to comment
Share on other sites

This should sort it

 

$optnamear = tep_db_query("SELECT `products_options_values_name` from `products_options_values` WHERE `products_options_values_id`='$id[products_options_values_id]'  ORDER BY `products_options_values_name` ASC") ;

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...