Jump to content

Recommended Posts

If made a search with only "ps3" word, only products will appear but not any category with this word.


Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

I finally remove the faulty display of categories and add an image of the product instead of "cart" icon (see attached picture).

 

Thank you to let me know if this feature sounds interesting.
At that time, I'll post an update of the contribution. :)

post-136115-0-38137700-1472596260_thumb.jpg


Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

@@milerwan

I finally remove the faulty display of categories and add an image of the product instead of "cart" icon (see attached picture).

 

Thank you to let me know if this feature sounds interesting.

 

I'm looking at several different 'Search' add-ons (including this one). I'd like to see your new features.

 

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@@milerwan

images are too small so icons seems to be better.


:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Share this post


Link to post
Share on other sites

@@ArtcoInc @@Gergely

Here are the improvements I have performed based on v1.2 :

  1. Display Image or Icon for product search result (set in admin)
  2. Ajustable product image width for mobile/tablet/tablet+/desktop devices
  3. Additional/optional search field Keywords into search frame (needs Header Tags SEO v3.x addon) : Very POWERFUL option!
  4. Extended number of result entries (total 30 instead of 15) : categories (15 -> 22) + products (5 -> 7) + more results (1)
  5. Fix highlight name crash in case of slash character use
  6. Mobile & Tablet css width fix improved (automatic switching for mobile and tablet horizontal/vertical size)
  7. Add french translation

Gergely, if you are interested to add this contribution to your current (locked) addon page, let me know by MP. :)
 

post-136115-0-27199300-1472757962_thumb.png

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

@@milerwan

mail sent. I have multi language experiencies so would be nice to mix them.


:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Share this post


Link to post
Share on other sites

@@milerwan

I've tried V1.3 and the option to search the description doesn't seem to work, can you investigate and let me know?

 

Otherwise, I like the new version, :-)

 

Thanks

Mike


osC BS gold live - osC CE in development (awesome)

Share this post


Link to post
Share on other sites

@@milerwan

I've tried V1.3 and the option to search the description doesn't seem to work, can you investigate and let me know?

 

Otherwise, I like the new version, :-)

 

Thanks

Mike

 

I have find a bug in the html transcription of the character "&" in the generated URL from this code in content_search.php :

'title' => MODULE_CONTENT_HEADER_STORE_SEARCH_MORE_PRODUCT,
'href' => tep_href_link('advanced_search_result.php', 'keywords=' . urlencode(str_replace(' ', ' ', $query)) . '&search_in_description=' . (MODULE_CONTENT_HEADER_STORE_SEARCH_FUNCTIONS == 'Descriptions' ? 1 : 0), $request_type),
'price' => null);

The "&" character is translated by "&".

 

For exemple, if you make a search of "m" product and click the "View more products on search page..." link, the link generated will be this one :

 

xxx/advanced_search_result.php?keywords=m&search_in_description=1

 

instead of 

 

xxx/advanced_search_result.php?keywords=m&search_in_description=1

 

Without right transcription of "&" character, the search in description can't work in that case.

 

So I have modified the code like this to make it works :

'href' => tep_href_link('advanced_search_result.php', 'keywords=' . urlencode(str_replace(' ', ' ', $query)), $request_type) . '&search_in_description=' . (MODULE_CONTENT_HEADER_STORE_SEARCH_FUNCTIONS == 'Descriptions' ? 1 : 0),

This bug comes from v1.1 of Store Search...

The newest version 1.4 is available in download from yesterday : http://addons.oscommerce.com/info/9504

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

@@milerwan, Thanks for the update, I'll test and let you know

Edited by Mikepo

osC BS gold live - osC CE in development (awesome)

Share this post


Link to post
Share on other sites

@@milerwan

just quickly tested on my test server.

 

I'm expecting the search to work on the product description, but the images attached show it doesn't

 

search my model works, search by product description doesn't, unless you use advanced search.

 

I've set the search options in admin to use the descriptions

 

Enable Extended Store Search Functions
Do you want to enable search function in descriptions?

Standard
Descriptions  (this is set)

 

Am I understanding the functionality correctly?

 

Mike

 

 

post-328457-0-26637200-1476381184_thumb.jpg

post-328457-0-24233500-1476381190_thumb.jpg


osC BS gold live - osC CE in development (awesome)

Share this post


Link to post
Share on other sites

@@milerwan

just quickly tested on my test server.

 

I'm expecting the search to work on the product description, but the images attached show it doesn't

 

search my model works, search by product description doesn't, unless you use advanced search.

 

I've set the search options in admin to use the descriptions

 

Enable Extended Store Search Functions

Do you want to enable search function in descriptions?

 

Standard

Descriptions  (this is set)

 

Am I understanding the functionality correctly?

 

Mike

The search in description works when you have more than 7 results in dropdown list.

You have to clic "View more results..." to access to the advanced_search listing results or clic on the magnifying glass icon of the bar.

 

If you want dropdown result with search in description, you must have to change some query into content_search.php file (ext/modules/content/header/content_search.php).

 

Do you have "header tags SEO" script in your store or some product keyword field installed ?

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

ok thanks, I now understand.

 

I was sure the the previous versions searched within the description field, but I must of been mistaken.

 

I do prefer this search add, so thanks for your help.

 

Mike


osC BS gold live - osC CE in development (awesome)

Share this post


Link to post
Share on other sites

To have better search results, if you have installed a product keywords field (from any SEO addon), you could add search in keyword option.
With this option, the search result is far more relevant.

So do you have SEO addon on your script ?
If it is, let me know which version and I will adapt the script for you.


Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

hi

I have  this seo addon

 

http://addons.oscommerce.com/info/8864

In this addon, product keyword field is named "products_seo_keywords" in database structure.

 

So, in "content_search.php" file (ext/modules/content/header/content_search.php), you have to just replace this sentence (in line 108) :

      $like_statement_product .= " (pd.products_name LIKE '%" . tep_db_input($product) . "%' OR pd.products_head_keywords_tag LIKE '%" . tep_db_input($product) . "%') AND ";

by this one :

      $like_statement_product .= " (pd.products_name LIKE '%" . tep_db_input($product) . "%' OR pd.products_seo_keywords LIKE '%" . tep_db_input($product) . "%') AND ";

Then, in admin, go to "Store Search Bar" module and choose "Keywords" option instead of "Model" option :

 

Additional Search Field (Keywords needs Header Tags SEO addon)

Do you want additional product search by Model or Keywords?

 

o Model

x Keywords

 

 

I think you will love it. ;)

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

@@milerwan, thanks for the change, I'll do some testing and see what the effects are.

Thanks again :) 

Mike


osC BS gold live - osC CE in development (awesome)

Share this post


Link to post
Share on other sites

First, thanks to everyone here that has worked on this add-on. Second, I'll be the first to admit that I know what I don't know :-

 

What I'm trying to do is adapt this to a *pre-gold* 2.3.4bs site. To do that, I've had to move this from a content module to a box. I've got it working ... sometimes. I'm starting off trying to get it to work with a single search word ... I'll advance to phrases later.

 

Depending on what I begin to type, the typeahead may wait for several characters before offering a suggestion, or may not offer any suggestion at all. If I then press enter (or click on the magnifying glass), the user is redirected to Advanced_Search, where the stock osC does it's thing.

 

So, while trying to debug this, I opened the Console window in Firefox, and watched what was happening as each letter was entered in the search box. In the below example, I was entering the search word 'mic'.

 

Upon entering the first letter, 'm', the console displays an error:

TypeError: r.name is null

As I type the second letter, 'i', the console displays the same error again.

 

Only when I type in the third letter, 'c', does the typeahead drop down a suggestion, and there is no additional error in the console.

 

post-327952-0-73085800-1476728543_thumb.jpg

 

I have used the console to examine what happens with this addon on a clean install of 2.3.4bs Edge, and there are no errors.

 

I am not yet ready to rebuild the whole site using 234bs Gold or Edge just to be able to add this addon. :- I've based this adaptation on @@Gergely 's original code, although I have reviewed the code from @@milerwan too.

 

So, I've reached the end of my abilities, and now need a little (lot?) guidance. Any ideas?

 

TIA

 

Malcolm

 

 

 

 


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@@milerwan

 

As I stated above, I am having troubles trying to convert this to a box module. I don't know if the problem is in my attempted conversion, or that I am trying to apply this to a pre-Gold version of 2.3.4bs.

 

Here's what I've done so far ...

<?php
/*
  $Id$

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

  Copyright (c) 2015 osCommerce

  Released under the GNU General Public License
*/

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

    function bm_store_search() {
      $this->title = MODULE_BOXES_STORE_SEARCH_TITLE;
      $this->description = MODULE_BOXES_STORE_SEARCH_DESCRIPTION;

      if ( defined('MODULE_BOXES_STORE_SEARCH_STATUS') ) {
        $this->sort_order = MODULE_BOXES_STORE_SEARCH_SORT_ORDER;
        $this->enabled = (MODULE_BOXES_STORE_SEARCH_STATUS == 'True');

        switch (MODULE_BOXES_STORE_SEARCH_CONTENT_PLACEMENT) {
          case 'Left Column':
          $this->group = 'boxes_column_left';
          break;
          case 'Header':
          $this->group = 'boxes_header';
          break;
          default:
          $this->group = 'boxes_column_right';
        }
      }
    }

    function execute() {
      global $request_type, $oscTemplate;

      $search_box = tep_navbar_store_search('btn-info', (MODULE_BOXES_STORE_SEARCH_FUNCTIONS == 'Descriptions'));

      // define typeahead scripts
      $script = '<script src="' . tep_href_link('ext/bootstrap-plugins/typeahead/bootstrap3-typeahead.min.js', null, $request_type) . '"></script>';
      $script .= '<script src="' . tep_href_link('ext/modules/content/header/store_search/content_searches.min.js', null, $request_type) . '"></script>';

      $oscTemplate->addBlock($script, 'footer_scripts');

      ob_start();
      include(DIR_WS_MODULES . 'boxes/templates/store_search.php');
      $template = ob_get_clean();

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


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

    function check() {
      return defined('MODULE_BOXES_STORE_SEARCH_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 Search Module', 'MODULE_BOXES_STORE_SEARCH_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_STORE_SEARCH_CONTENT_PLACEMENT', 'Header', 'Should the module be loaded in the left or right column or directly in the header?', '6', '1', 'tep_cfg_select_option(array(\'Left Column\', \'Right Column\', \'Header\'), ', 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 ('Enable Extended Store Search Functions', 'MODULE_BOXES_STORE_SEARCH_FUNCTIONS', 'Standard', 'Do you want to enable search function in descriptions?', '6', '1', 'tep_cfg_select_option(array(\'Standard\', \'Descriptions\'), ', now())");

      tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Pages', 'MODULE_BOXES_STORE_SEARCH_PAGES', '" . implode(';', $this->get_default_pages()) . "', 'The pages to add the Store Search\'s results.', '6', '0', 'bm_store_search_show_pages', 'bm_store_search_pages(', 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_STORE_SEARCH_SORT_ORDER', '31', '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_STORE_SEARCH_STATUS',
                   'MODULE_BOXES_STORE_SEARCH_CONTENT_PLACEMENT',
                   'MODULE_BOXES_STORE_SEARCH_FUNCTIONS',
                   'MODULE_BOXES_STORE_SEARCH_PAGES',
                   'MODULE_BOXES_STORE_SEARCH_SORT_ORDER');
    }

    function get_default_pages() {
      return array( 'shipping.php',
                    'contact_us.php',
                    'conditions.php',
                    'cookie_usage.php',
                    'privacy.php',
                    'login.php',
                    'address_book.php',
                    'create_account.php',
                    'account_history.php',
                    'advanced_search.php',
                    'products_new.php',
                    'reviews.php',
                    'ssl_check.php',
                    'specials.php',
                    'shopping_cart.php');
    }
  }

  function tep_navbar_store_search($btnclass ='btn-default', $description = true) {
    global $request_type;

    $search_link = '<div class="searchbox-margin">';
    $search_link .= tep_draw_form('quick_find', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', $request_type, false), 'get', 'class="form-horizontal"');
    $search_link .= '    <div class="input-group">' .
                            tep_draw_input_field('keywords', '', 'required placeholder="' . MODULE_BOXES_STORE_SEARCH_PLACEHOLDER . '" id="quick_search" data-provide="typeahead" autocomplete="off" style="margin-right:-2px;"', 'search') .
                     '        <span class="input-group-btn"><button type="submit" class="btn ' . $btnclass .'" style="border-top-left-radius: 0px; border-bottom-left-radius: 0px;"><i class="glyphicon glyphicon-search"></i></button></span>';
    if (tep_not_null($description) && ($description === true)) {
      $search_link .= tep_draw_hidden_field('search_in_description', '1');
    }
    $search_link .= '    </div>' .
                    '  </div>';

    $search_link .=  tep_hide_session_id() . '</form>';

    return $search_link;
  }

  function bm_store_search_show_pages($text) {
    return nl2br(implode("\n", explode(';', $text)));
  }

  function bm_store_search_pages($values, $key) {
    global $PHP_SELF;

    $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
    $files_array = array();
    if ($dir = @[member=dir](DIR_FS_CATALOG)) {
      while ($file = $dir->read()) {
        if (!is_dir(DIR_FS_CATALOG . $file)) {
          if (substr($file, strrpos($file, '.')) == $file_extension) {
            $files_array[] = $file;
          }
        }
      }
      sort($files_array);
      $dir->close();
    }

    $values_array = explode(';', $values);

    $output = '';
    foreach ($files_array as $file) {
      $output .= tep_draw_checkbox_field('bm_store_search_file[]', $file, in_array($file, $values_array)) . ' ' . tep_output_string($file) . '<br />';
    }

    if (!empty($output)) {
      $output = '<br />' . substr($output, 0, -6);
    }

    $output .= tep_draw_hidden_field('configuration[' . $key . ']', '', 'id="htrn_files"');

    $output .= '<script>
                function htrn_update_cfg_value() {
                  var htrn_selected_files = \'\';

                  if ($(\'input[name="bm_store_search_file[]"]\').length > 0) {
                    $(\'input[name="bm_store_search_file[]"]:checked\').each(function() {
                      htrn_selected_files += $(this).attr(\'value\') + \';\';
                    });

                    if (htrn_selected_files.length > 0) {
                      htrn_selected_files = htrn_selected_files.substring(0, htrn_selected_files.length - 1);
                    }
                  }

                  $(\'#htrn_files\').val(htrn_selected_files);
                }

                $(function() {
                  htrn_update_cfg_value();

                  if ($(\'input[name="bm_store_search_file[]"]\').length > 0) {
                    $(\'input[name="bm_store_search_file[]"]\').change(function() {
                      htrn_update_cfg_value();
                    });
                  }
                });
                </script>';

    return $output;
  }
?>

TIA

 

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@@ArtcoInc

Change the following in ext/modules/../content_searches.php
 

MODULE_CONTENT_HEADER_STORE_SEARCH_PAGE

to:

MODULE_BOXES_STORE_SEARCH_PAGES

:blink:
osCommerce based shop owner with minimal design and focused on background works. When the less is more.
Email managment with tracking pixel, package managment for shipping, stock management, warehouse managment with bar code reader, parcel shops management on 3000 pickup points without local store.

Share this post


Link to post
Share on other sites

@@Gergely

 

I had ...

<?php
/*
  $Id$ version 1.1 for oscommerce 2.3.4BS

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

  Copyright (c) 2015 osCommerce

  Released under the GNU General Public License
*/



// get rid of the individual calls for files and replace it with the only one we need, application_top.php
// from here all other files necessary are also included.
  chdir('../../../../../');

  require('includes/application_top.php');
  include(DIR_WS_LANGUAGES . $language . '/modules/content/header/cm_header_store_search.php');

  if (isset($_POST['query'])) {
    $query = tep_db_prepare_input($_POST['query']);
  } else {

//nothing to do
    $query = "";
    exit();
  }

//here we can replace certain phrases that people may search for that are wrong, i have left my examples below.
//for example i have people add food or foods onto the end of search phrases, but food is rarely used in product names.
//or for if people add spaces where there shouldnt be or remove spaces when there should be

  if ($language == 'english') {
    $query = str_replace(' food','',$query);
    $query = str_replace(' food','',$query);
    $query = str_replace('jameswellbeloved','james wellbeloved',$query);
    $query = str_replace('jameswell beloved','james wellbeloved',$query);
    $query = str_replace('ferrets','ferret',$query);
    $query = str_replace('sawdust','wood shavings',$query);
    $query = str_replace('saw dust','wood shavings',$query);
    $query = str_replace('naturesdiet','naturediet',$query);
    $query = str_replace('natures diet','naturediet',$query);
    $query = str_replace('drjohns','dr johns',$query);
  }

//Explode This Query

  $query_exploded = array();
  $query_exploded = explode(' ', $query);
  $query_exploded = array_unique($query_exploded);

//if a characters are only "b" or "B" do nothing!
  if (($key = array_search("b", $query_exploded)) !== false) { unset($query_exploded[$key]); }
  if (($key = array_search("B", $query_exploded)) !== false) { unset($query_exploded[$key]); }

//for highlight rule
  arsort($query_exploded);
  $query_exploded_new = '';
  foreach ($query_exploded as $g) {

// <b> is not search engine sensitive
    $query_exploded_new .= '<b>' . $g . '</b>' . "E_OF_L";
  }

  $query_exploded_new = substr($query_exploded_new, 0, -6);
  $query_exploded_highlight = explode("E_OF_L", $query_exploded_new);

//Generate Like Statement for Each Word To Find Categories, Second Level, That Match

  foreach ($query_exploded as $g) {
    $like_statement .= " (cd.categories_name LIKE '%" . tep_db_input($g) . "%' OR
                          cd.categories_description LIKE '%" . tep_db_input($g) . "%') AND ";
  }

  $like_statement = substr($like_statement, 0, -4); //Remove That Last AND

//Select categories, that are second level, and that match our query

  $sqlquery = tep_db_query("SELECT distinct(c.categories_id),
                                           cd.categories_name,
                                           cd.categories_description,
                                            c.parent_id
                            FROM categories_description cd,
                                 categories c
                            WHERE cd.categories_id = c.categories_id
                              AND " . $like_statement . "
                              AND cd.language_id = '" . (int)$languages_id . "'
                            LIMIT 15");

//For Each Category We Found

  $categories_found = '';

  if (tep_db_num_rows($sqlquery)) {

    while ($row = tep_db_fetch_array($sqlquery)) {
      $url_title = ucwords(strtolower($row['categories_name']));

//highlight
      $url_title = str_ireplace($query_exploded, $query_exploded_highlight, $url_title);

      $array[] = array('icon'  => "sitemap",
                       'title' => $url_title,
                       'href'  => tep_href_link('index.php', 'cPath=' . $row['categories_id'], $request_type),
                       'price' =>null);
    }
  }

  $like_statement = '';

//We Have All Suggested Categories



//Find Suggested Products

  foreach ($query_exploded as $g) {
//Prevent SQL Injection Attempts
    $g = str_replace(array("'", ";", "*", "(", ")"), '',$g);
    $like_statement .= " (pd.products_name LIKE '%" . tep_db_input($g) . "%' OR
                           p.products_model LIKE '%" . tep_db_input($g) . "%' OR
                          pd.products_description LIKE '%" . tep_db_input($g) . "%') AND ";
  }

//Remove the Last And

  $like_statement = substr($like_statement, 0, -4);

  $sqlquery = tep_db_query("SELECT distinct(p.products_id),
                                           pd.products_name,
                                           pd.products_description,
                                            p.products_price,
                                            p.products_tax_class_id
                            FROM products_description pd,
                                 products p
                            WHERE " . $like_statement . "
                              AND pd.products_id = p.products_id
                              AND pd.language_id = '" . (int)$languages_id . "'
                              AND p.products_status
                            LIMIT 6");


  $r = 0; //Set R
  if (tep_db_num_rows($sqlquery)) {
    while ($row = tep_db_fetch_array($sqlquery)) {
      $r++;
      $url_title = str_replace('’', '', $row['products_name']);

//highlight
      $url_title = str_ireplace($query_exploded, $query_exploded_highlight, $url_title);

      if ($r > 5) {
        $array[] = array('icon'  => "plus-circle",
                         'title' => MODULE_CONTENT_HEADER_STORE_SEARCH_MORE_PRODUCT,
                         'href' => tep_href_link('advanced_search_result.php', 'keywords=' . urlencode(str_replace(' ', ' ', $query)), $request_type) . '&search_in_description=' . (MODULE_CONTENT_HEADER_STORE_SEARCH_FUNCTIONS == 'Descriptions' ? 1 : 0),

                         'price' =>null);
        break;

      } else {

        if ($new_price = tep_get_products_special_price($row['products_id'])) {
          $price = '<s>' . $currencies->display_price($row['products_price'], tep_get_tax_rate($row['products_tax_class_id'])) . '</s> <span class="productSpecialPrice">' . $currencies->display_price($new_price, tep_get_tax_rate($row['products_tax_class_id'])) . '</span>';

        } else {
          $price = $currencies->display_price($row['products_price'], tep_get_tax_rate($row['products_tax_class_id']));
        }

        $array[] = array('icon'  => "cart-plus",
                         'title' => $url_title,
                         'href'  => tep_href_link('product_info.php', 'products_id=' . $row['products_id'], $request_type),
                         'price' => $price);
      }
    }
  } else {

    $array[] = array('icon'  => "wrench",
                     'title' => MODULE_CONTENT_HEADER_STORE_SEARCH_NOT_FOUND,
                     'href'  => tep_href_link('advanced_search.php', 'keywords=' . urlencode(str_replace(' ', '+', $query)), $request_type),
                     'price' => null);
  }


// start content searches in files

  if (tep_not_null(MODULE_BOXES_STORE_SEARCH_PAGES)) {
    $content_files = array();

    foreach (explode(';', MODULE_BOXES_STORE_SEARCH_PAGES) as $page) {
      $page = trim($page);

      if (!empty($page)) {
        $content_files[] = $page;
      }
    }

    foreach ($content_files as $file_name) {

      $file = DIR_WS_LANGUAGES . $language . '/' . $file_name;

      $lines = @file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);

      if ($lines !== false) {
        $n = 0;
        foreach ($lines as $line) {
          $n++;
// skip header
          if ( $n>8 ) { //empty rows shifted in @file!
// Check if the line contains the string we're looking for, and add if it does
            foreach ($query_exploded as $q) {
              if (strpos(strtolower($line), strtolower($q)) !== false) {

                $array[] = array('icon'  => "file",
                                 'title' => sprintf( MODULE_CONTENT_HEADER_STORE_SEARCH_PAGE, substr(basename($file), 0, -4)),
                                 'href'  => tep_href_link($file_name, null, $request_type),
                                 'price' => null);
                break 2;
              }
            }
          }
        }
      }

    }
  }

// build json
  echo json_encode($array);

?>

I did leave the following:

 

MODULE_CONTENT_HEADER_STORE_SEARCH_MORE_PRODUCT

 

MODULE_CONTENT_HEADER_STORE_SEARCH_FUNCTIONS

 

MODULE_CONTENT_HEADER_STORE_SEARCH_NOT_FOUND

 

MODULE_CONTENT_HEADER_STORE_SEARCH_PAGE

 

as these are defined in the language file, and that is still in place.

 

(and yes, I did add searching the description field too)

 

Thank you!

 

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

@@milerwan

 

As I stated above, I am having troubles trying to convert this to a box module. I don't know if the problem is in my attempted conversion, or that I am trying to apply this to a pre-Gold version of 2.3.4bs.

First, uninstall/disable your current box version and install the last Store Search header module (v1.4).

See if you have the bug you told before (with "mic" word).

If no bug then you could try to modify the current header module on box module.


Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

@@milerwan

 

Using a clean backup of my pre-gold 2.3.4bs site, I removed all instances of any search enhancements. I then installed the latest version (v1.4) of Store Search.

 

Since my site is a *pre-gold* version, I had to add to: /includes/header.php

<!--  Added to test Search add-on ... 10-19-16 -->
  <div class="modular-header">
    <?php echo $oscTemplate->getContent('header'); ?>
  </div>

I also had to add support for the Font Awesome to: /includes/template_top.php

<!-- font awesome -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">

Both of these are trivial changes, considering that I am using a pre-gold version.

 

 

With the above changes, the new search box now displays (I can fix the position later).

 

(I am using a copy of the database from my live site, so the products shown will be different )

 

1) When I start searching for 'mic' ... after the first letter, I get some results ...

 

post-327952-0-18163900-1476914323_thumb.jpg

 

So far, so good ...

 

2) I then search for the word 'cover', a word used in both a category name and in product models (model is selected in Admin). The first letter returned the same error as before:

Type error: r.name is null

The second letter returns the same error. The third letter finally returns some results (and no error)

 

post-327952-0-52248000-1476914421_thumb.jpg

 

 

3) I then search for the word 'kevlar', a word used in many descriptions and sub-category names. All five letters return the same error, with no search results ...

 

post-327952-0-63528500-1476914684_thumb.jpg

 

 

in case it makes any difference, this is all running on a WAMP server inhouse.

PHP 5.4.16

MySQL 5.6.12

 

 

 

PS: In the installation instructions for v1.4, you fail to mention to copy the following new files which are included in the package:

 

ext/bootstrap-plugins/typeahead/bootstrap3-typeahead.min.js

 

includes/modules/content/header/templates/store_search.php

 

Thank you for all your help!!!

 

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

Further testing ...

 

One would think that almost every letter of the alphabet would be used somewhere in a part name, model, or description. So, I just did a search for each letter, one at a time.

 

1) We know that a single 'b' is ignored

 

2) The following letters returned a suggestion (ie: no error in the console): d, f, j, m, q, w

 

3) The following letters generated an error, and did not return a suggestion: a, c, e, g, h, i, k, l, n, o, p, r, s, t, u, v, x, y, z

 

-plus-

 

4) Every single number (0-9) returned a suggestion (ie: no error in the console)

 

 

So, I then tried 2-letter combinations ...

 

aa -> no products found

ab -> no products found, but listed 4 pages

ac -> matched 6 products that include AC in the part number, plus 9 pages

ad -> no products found, but listed 15 pages

ae -> no products found

af -> matched 6 products that include AF in the part number

ag -> no products found, but listed 6 pages

ah -> no products found

 

etc.

 

so initially, it looks like a 2-letter combination works. But, this is not always the case. I can try:

 

co -> should return 'Cover Mitts', but returns nothing

sl -> should return 'sleeves', but returns nothing

ze -> should return 'Zetex', but returns nothing

he -> should return 'Heat ... ", but returns nothing

kn -> should return 'knit', but returns nothing

 

etc

 

So, it's working *sometimes*, and I'm not seeing a pattern ...

 

Malcolm


Get the latest Responsive osCommerce CE (community edition) here .

Share this post


Link to post
Share on other sites

PS: In the installation instructions for v1.4, you fail to mention to copy the following new files which are included in the package:

 

ext/bootstrap-plugins/typeahead/bootstrap3-typeahead.min.js

 

includes/modules/content/header/templates/store_search.php

 

In install instructions (from install.html file), from v1.2 to v1.3, these files need to be updated.

And for v1.3 to v1.4, only content_searches.php have been modified.

For anyone that haven't already install this module full package is needed.

 

 

Further testing ...

 

One would think that almost every letter of the alphabet would be used somewhere in a part name, model, or description. So, I just did a search for each letter, one at a time.

 

1) We know that a single 'b' is ignored

 

2) The following letters returned a suggestion (ie: no error in the console): d, f, j, m, q, w

 

3) The following letters generated an error, and did not return a suggestion: a, c, e, g, h, i, k, l, n, o, p, r, s, t, u, v, x, y, z

 

-plus-

 

4) Every single number (0-9) returned a suggestion (ie: no error in the console)

 

 

So, I then tried 2-letter combinations ...

 

aa -> no products found

ab -> no products found, but listed 4 pages

ac -> matched 6 products that include AC in the part number, plus 9 pages

ad -> no products found, but listed 15 pages

ae -> no products found

af -> matched 6 products that include AF in the part number

ag -> no products found, but listed 6 pages

ah -> no products found

 

etc.

 

so initially, it looks like a 2-letter combination works. But, this is not always the case. I can try:

 

co -> should return 'Cover Mitts', but returns nothing

sl -> should return 'sleeves', but returns nothing

ze -> should return 'Zetex', but returns nothing

he -> should return 'Heat ... ", but returns nothing

kn -> should return 'knit', but returns nothing

 

etc

 

So, it's working *sometimes*, and I'm not seeing a pattern ...

 

Malcolm

 

I have the same issue when I work in localhost.

So when your shop will be online, you will have full result from the first character.

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

So, I then tried 2-letter combinations ...

 

aa -> no products found

ab -> no products found, but listed 4 pages

ac -> matched 6 products that include AC in the part number, plus 9 pages

ad -> no products found, but listed 15 pages

ae -> no products found

af -> matched 6 products that include AF in the part number

ag -> no products found, but listed 6 pages

ah -> no products found

 

etc.

 

so initially, it looks like a 2-letter combination works. But, this is not always the case. I can try:

 

co -> should return 'Cover Mitts', but returns nothing

sl -> should return 'sleeves', but returns nothing

ze -> should return 'Zetex', but returns nothing

he -> should return 'Heat ... ", but returns nothing

kn -> should return 'knit', but returns nothing

 

To have dropdown product results you need to have the combination letter in product name.

The result pages you have from search in product description is normal.

 

Also I noticed that when it comes to name of categories, only the first words are taken into account when searching, not the last.

So check if the word you search is part of the first words or the last words of the category name.

 

Do you have a link to your "work in progess / test" store ?

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

PS: In the installation instructions for v1.4, you fail to mention to copy the following new files which are included in the package:

 

ext/bootstrap-plugins/typeahead/bootstrap3-typeahead.min.js

 

includes/modules/content/header/templates/store_search.php

After check the "ext/bootstrap-plugins/typeahead/bootstrap3-typeahead.min.js" file is same as before, no modification from me.

Maybe would you say "\ext\modules\content\header\store_search\content_searches.min.js" file perhaps ?!?

Edited by milerwan

Osc v2.3.4 BS "custom"
PHP 7.3 compatible (710 modified files => o_O')

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×