Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: MODUL: jQuery Autocomplete (ähnlich Ajax Search Suggest, IntelliSearch)

    WayneTsun

    • Fördermitglied
    • Beiträge: 1.082
    • Geschlecht:
    Hi noRiddle,

    Danke für Deine Hilfe. Du hast vollkommen recht, ich hatte den Code nur versuchsweise in '1' abgeändert, um zu sehen, ob es ein Ergebnis gibt, wenn die Sprache 'englisch' ist. Das funktioniert auf diesem Weg.

    $_SESSION['language_id] ist in der autocomplete.php definiert als $languages_id und wird dann in der Abfrage so verwendet:

    Code: PHP  [Auswählen]
                    cd.language_id = '" . (int)$languages_id . "'

    Leider bin ich immer noch nicht weiter und kann mir den Fehler nicht erklären. Es scheint eben in der Abfrage immer als Ergebnis der $languages_id = '2' zu geben.

    Beste Grüße,
    Wayne
    Werbung / Banner buchen

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.990
    • Geschlecht:
    Wo und wie ist den $languages_id definiert ?

    Gruß,
    noRiddle

    WayneTsun

    • Fördermitglied
    • Beiträge: 1.082
    • Geschlecht:
    In der /autocomplete.php gleich nach den Funktionseinstellungen heisst es:

    Code: PHP  [Auswählen]
    require('includes/application_top.php');
    $languages_id = $_SESSION['languages_id'];

    Ich habe herausgefunden, womit das zusammen hängt, habe aber keine Lösung dazu. Ich habe das ganze ohne seo-friendly links und ohne die nach dem Modul von Alkim Media (ERWEITERUNG: canonical Tags (DC/SEO) für modified eCommerce Shopsoftware) angepasste metatags.php und .htaccess einwandfrei sowohl in Englisch wie auch im Deutschen zum laufen gebracht. Also daran liegt es. Aber was da nun anzupassen ist...? :glaskugel:

    Vielen Dank für den Hilfeversuch!

    Beste Grüße,
    Wayne

    WayneTsun

    • Fördermitglied
    • Beiträge: 1.082
    • Geschlecht:
    Hat jemand eventuell dieses Modul gemeinsam mit dem Modul canonical Tags von Alkim installiert? http://www.modified-shop.org/forum/index.php?topic=13494.msg151019#msg151019

    Beste Grüße,
    Wayne

    WayneTsun

    • Fördermitglied
    • Beiträge: 1.082
    • Geschlecht:
    Also da komme ich auch nicht weiter. Bei Eingabe von
    Code: PHP  [Auswählen]
    www.meinedomain.de/en/autocomplete.php?term=test
    erhalte ich erfolgreich die richtige Ausgabe mit den Artikeln in Englisch.

     :crazy:

    Hat vielleicht noch jemand eine Idee?

    Beste Grüße,
    Wayne

    PS: Üblicherweise führe ich ja keine Selbstgespräche...altersbedingt. Aber vielleicht mache ich das öfter und hab's vergessen... auch altersbedingt?  :blower:

    karabey

    • Schreiberling
    • Beiträge: 320
    • Geschlecht:
    Ich hätte da eine Frage über die Auflistung der Ergebnisse.

    Kann man die Auflistung der Ergebnisse je nach Priorität des gesamten Suchbegriffes umändern?
    Nach der Suche in Beschreibung haben die Ergebnisse der Beschreibung höhere Priorität als die eigentlichen Produkte und Kategorien.
    Code: PHP  [Auswählen]
    'SEARCH_IN_PRODUCTS_DESCRIPTION' => false,

    WayneTsun

    • Fördermitglied
    • Beiträge: 1.082
    • Geschlecht:
    @karabey
    Wie genau meinst Du das?

    Beste Grüße,
    Wayne

    PS: Mein Problem ist leider auch noch pending. Hab keinen Ansatz mehr dazu und es nun nur im Deutschen aktiviert.

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.990
    • Geschlecht:
    Hey Wayne.
    Könntest du mal kurz versuchen in der box_search.html folgendes irgendwo einzugeben ?
    Code: PHP  [Auswählen]
    {php}
    echo '<pre>'.$_SESSION['languages_id'].'</pre>';
    {/php}
    Dann im Frontend schauen was ausgegeben wird, in beiden Sprachen.

    Gruß,
    noRiddle

    arno_nuehm

    • Mitglied
    • Beiträge: 102
    • Geschlecht:
    Hi,

    hat schon jemand die VPE in der Anzeige ergänzt?
    Will mir leider nicht gelingen. :(

    Gruß
    Manu

    WayneTsun

    • Fördermitglied
    • Beiträge: 1.082
    • Geschlecht:
    @noRiddle
    Sorry, ich war nicht mehr online gewesen. Was schade!
    Hab den Code nun eingesetzt und als Ausgabe jeweils die korrekte language_id erhalten. Also 1 für Englisch und 2 für Deutsch.

    Beste Grüße,
    Wayne

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.990
    • Geschlecht:
    Das wundert mich jetzt aber sehr.
    Du sagtest doch, daß, wenn du die ID hard-codiert eingibst alles okay ist.
    Unser Test zeigt doch, daß die $languages_id bekannt ist.
    Sehr seltsam.
    Vielleicht postest du mal deine komplette autocomplete.php im Anhang,
    mal anschauen...

    Gruß,
    noRiddle

    WayneTsun

    • Fördermitglied
    • Beiträge: 1.082
    • Geschlecht:
    Mich wundert das auch schon die ganze Zeit. :-/

    Wenn ich in den Abfragen $_languages_id mit 1 ersetze funktioniert es.

    Damit das auch Live sichtbar ist, habe ich das Modul zur Überprüfung jetzt auch im englischen wieder eingeschaltet.

    Hier die autocomplete.php:
    Code: PHP  [Auswählen]
    <?php
    /* -----------------------------------------------------------------------------------------
       jQuery Autocomplete

       Changelog:
       2011-04-18: Soundex/Koelner search in category-names by TechWay
       2011-04-19: NEW LINK DEFINITION by web28 www.rpa-com.de
       2011-04-19: products_short_description added by TechWay
       2011-04-20: NEW option SHOW_PRODUCT_IMAGE and function productImage, products/categoriesLink by web28 www.rpa-com.de
       2011-04-21: noimage.gif if no products_image, cleaned short_description (no html-tags), products_price added by TechWay
       2011-04-22: NEW functions handling, NEW option SHOW_PRODUCT_PRICE  by web28 www.rpa-com.de

       Released under the GNU General Public License
       ---------------------------------------------------------------------------------------*/


    //The settings you can change:
    $searchConfig = array(
            'USE_SUMA_LINKS' => true,                                       // Would you like SUMA Links? Possible values: true / false. Standard: true
            'SEARCH_IN_PRODUCTS_NAME' => true,                              // Would you like to search in the product names? Possible values: true / false. Standard: true
            'SEARCH_IN_PRODUCTS_KEYWORDS' => true,                  // Would you like to search in the product keywords? Possible values: true / false. Standard: true
            'SEARCH_IN_PRODUCTS_DESCRIPTION' => true,               // Would you like to search in the product description? Possible values: true / false. Standard: true
            'SEARCH_IN_PRODUCTS_SHORT_DESCRIPTION' => false,        // Would you like to search in the product short description? Possible values: true / false. Standard: true
            'SEARCH_IN_CATEGORY_NAMES' => true,                             // Would you like to search in the category names? Possible values: true / false. Standard: true
            'SEARCH_IN_CATEGORY_DESCRIPTION' => false,              // Would you like to search in the category names? Possible values: true / false. Standard: true
            'SEARCH_IN_PRODUCTS_MODEL' => false,                    // Would you like to search in the products model? Possible values: true / false. Standard: false
            'SEARCH_IN_PRODUCTS_EAN' => false,                              // Would you like to search in the products ean? Possible values: true / false. Standard: false
            'SHOW_PRODUCT_IMAGE' => true,                                   // Would you like to show products_image? Possible values: true / false. Standard: false
            'SHOW_PRODUCT_PRICE' => true,                                   // Would you like to show products_price? Possible values: true / false. Standard: false
            'SHOW_PRODUCT_DESC' => true,                                    // Would you like to show products_short_description? Possible values: true / false. Standard: false
            'PRODUCT_DESC_MAX_LENGTH' => 100,                               // Max length of products_short_description. Possible values: INTEGER, Standard: 100
            'SUBSTRING_COUNT' => 40,                                                // Length of results in the list (signs). Possible values: INT from 1 to 256. Standard: 40
            'SUBSTRING_FINALIZER' => ' ...',                                // Signs after a word is cutted in the suggestlist. Possible values: Any String. Standard: ' ...'
            'PRODUCT_RESULT_COUNT' => 10,                                   // How many found products should be displayed? Possible values: INT from 1 to 256. Standard: 10
            'CATEGORY_RESULT_COUNT' => 5,                                   // How many found categories should be displayed? Possible values: INT from 1 to 256. Standard: 5
            'SHOW_CATEGORY_WITH_PRODUCT' => false,                  // Would you like to show the category name in the product result like "category => productname" Possible values: true / false. Standard: false
            'GROUP_RESULTS' => true,                                                // Would you like to group the results by the category_name? Possible values: true / false. Standard: true
            'SEVERAL_KEYWORDS_AND' => true,                                 // Search for several keywords with AND-logic. Possible values: true / false. Standard: true
            'SOUNDEX_SEARCH_PRODUCT_NAMES' => false,                // Would you like to search for keyword with soundex-method (sounds like) Possible values: true / false. Standard: false
            'SOUNDEX_SEARCH_CATEGORY_NAMES' => false,               // Would you like to search for keyword with soundex-method (sounds like) Possible values: true / false. Standard: false
            'KOELNER_PHONETIK_PRODUCT_NAMES' => true,               // Would you like to search for keyword with koelner-method (sounds like) Possible values: true / false. Standard: false
            'KOELNER_PHONETIK_CATEGORY_NAMES' => false,             // Would you like to search for keyword with koelner-method (sounds like) Possible values: true / false. Standard: false
            'FILTER_LINKED_PRODUCTS' => false                               // Would you like to show the linked products only one time? Possible values: true / false. Standard: true
            );

    //Settings END

    require('includes/application_top.php');
    $languages_id = $_SESSION['languages_id'];


    $ent_keyword = trim(htmlentities($_GET['term']));
    if (!strlen($ent_keyword)) {
            unset($searchConfig);
            return json_encode(array());
    }
    $ent_keyword = ($ent_keyword != $_GET['term']) ? addslashes($ent_keyword) : false;

    $keyword = mysql_real_escape_string(urldecode($_GET['term']));

    $keyword = str_replace(array('%', '_'), array('\%', '\_'), $keyword);
    $ent_keyword = str_replace(array('%', '_'), array('\%', '\_'), $ent_keyword);

    //initialize array for results
    $return_arr = array();
    $num_rows_cat=0;

    $str_group_by = "";
    if ($searchConfig['FILTER_LINKED_PRODUCTS'] == 1) {
            $str_group_by = " GROUP BY p.products_id ";
    }

    //BOF - Search in category_name ################################################
    if ($searchConfig['SEARCH_IN_CATEGORY_NAMES'] == 1 || $searchConfig['SEARCH_IN_CATEGORY_DESCRIPTION'] == 1){
            $where_str_cat = " AND ( ";
            $firstCatItem = true;

            if ($searchConfig['SEARCH_IN_CATEGORY_NAMES'] == 1 ) {
                    !$firstCatItem ? $where_str_cat.=" OR " : false;
                    if($searchConfig['SEVERAL_KEYWORDS_AND'] == 1) {
                            $temp_ary = explode(' ', $keyword);
                            $temp_ary2 = array();
                            for ( $i = 0; $i < count($temp_ary); ++$i )
                            {
                                    $temp_ary2[] = " cd.categories_name LIKE '%" . $temp_ary[$i] . "%' ";
                            }
                            if ( count($temp_ary2) > 0 )
                            {
                                    $where_str_cat.= ' ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                            }

                            if ($ent_keyword)
                            {
                                    $temp_ary = explode(' ', $ent_keyword);
                                    $temp_ary2 = array();
                                    for ( $i = 0; $i < count($temp_ary); ++$i )
                                    {
                                            $temp_ary2[] = " cd.categories_name LIKE '%" . $temp_ary[$i] . "%' ";
                                    }
                                    if ( count($temp_ary2) > 0 )
                                    {
                                            $where_str_cat.= ' OR ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                                    }
                            }

                    } else {
                            $where_str_cat .= "cd.categories_name LIKE '%" . $keyword . "%' ";
                            $where_str_cat .= ($ent_keyword) ? "OR cd.categories_name LIKE ('%".$ent_keyword."%') " : '';
                    }
                    $firstCatItem=false;
            }

            if ($searchConfig['SEARCH_IN_CATEGORY_DESCRIPTION'] == 1 ) {
                    !$firstCatItem ? $where_str_cat.=" OR " : false;
                    if($searchConfig['SEVERAL_KEYWORDS_AND'] == 1) {
                            $temp_ary = explode(' ', $keyword);
                            $temp_ary2 = array();
                            for ( $i = 0; $i < count($temp_ary); ++$i )
                            {
                                    $temp_ary2[] = " cd.categories_description LIKE '%" . $temp_ary[$i] . "%' ";
                            }
                            if ( count($temp_ary2) > 0 )
                            {
                                    $where_str_cat.= ' ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                            }

                            if ($ent_keyword)
                            {
                                    $temp_ary = explode(' ', $ent_keyword);
                                    $temp_ary2 = array();
                                    for ( $i = 0; $i < count($temp_ary); ++$i )
                                    {
                                            $temp_ary2[] = " cd.categories_description LIKE '%" . $temp_ary[$i] . "%' ";
                                    }
                                    if ( count($temp_ary2) > 0 )
                                    {
                                            $where_str_cat.= ' OR ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                                    }
                            }

                    } else {
                            $where_str_cat .= "cd.categories_name LIKE '%" . $keyword . "%' ";
                            $where_str_cat .= ($ent_keyword) ? "OR cd.categories_name LIKE ('%".$ent_keyword."%') " : '';
                    }
                    $firstCatItem=false;
            }

            $where_str_cat .= " ) ";

      //Build SQL-Query for category-search
      $group_check = ''; //DokuMan - 2010-02-28 - set undefined variable group_check
      if (GROUP_CHECK == 'true') {
        $group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
        $group_check_c = " AND c.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
        } else {
          unset ($group_check);
          unset ($group_check_c);
      }

      //BOF - web28 - 2011-04-22 - NEW SQL QUERY and change $where_str to %s
      $sql_str_cat = "SELECT cd.categories_id,
                             cd.categories_name
                        FROM "
    .TABLE_CATEGORIES." c
                  INNER JOIN "
    .TABLE_CATEGORIES_DESCRIPTION." cd
                          ON c.categories_id = cd.categories_id
                       WHERE cd.language_id = '"
    .(int)$languages_id."'
                       "
    .$group_check_c."
                         AND c.categories_status = '1'
                             %s
                    ORDER BY cd.categories_name
                       LIMIT 0,"
    .$searchConfig['CATEGORY_RESULT_COUNT'];
      //EOF - web28 - 2011-04-22 - NEW SQL QUERY and change $where_str to %s

            $fetch_cat = xtc_db_query(sprintf($sql_str_cat,$where_str_cat)); //web28 - 2011-04-22 - using sprintf
            $num_rows_cat = mysql_num_rows($fetch_cat);

      while ($row_cat = xtc_db_fetch_array($fetch_cat)) {
        getCatReturnArray($row_cat,TEXT_AUTOCOMPLETE_CATEGORIES); //web28 - 2011-04-22 - New function handling
      }

            //Soundex Category Names
            if ($num_rows_cat == 0 && $searchConfig['SOUNDEX_SEARCH_CATEGORY_NAMES'] == 1) {

                    $where_str_cat = " AND ( soundex_match('".$keyword."', cd.categories_name, ' ') = 1 ) ";

                    $fetch_cat = xtc_db_query(sprintf($sql_str_cat,$where_str_cat)); //web28 - 2011-04-22 - using sprintf
                    $num_rows_cat = mysql_num_rows($fetch_cat);

        while ($row_cat = xtc_db_fetch_array($fetch_cat)) {
          getCatReturnArray($row_cat,TEXT_AUTOCOMPLETE_SOUNDEX); //web28 - 2011-04-22 - New function handling
        }
            }

            //Koelner Phonetik category names
            if ($num_rows_cat == 0 && $searchConfig['KOELNER_PHONETIK_CATEGORY_NAMES'] == 1) {

                    $where_str_cat = " AND ( koelner_match('".$keyword."', cd.categories_name, ' ') = 1 ) ";

                    $fetch_cat = xtc_db_query(sprintf($sql_str_cat,$where_str_cat)); //web28 - 2011-04-22 - using sprintf
                    $num_rows_cat = mysql_num_rows($fetch_cat);

        while ($row_cat = xtc_db_fetch_array($fetch_cat)) {
          getCatReturnArray($row_cat,TEXT_AUTOCOMPLETE_SOUNDEX); //web28 - 2011-04-22 - New function handling
        }
            }
    }
    //EOF - Search in category_name ################################################


    //BOF - Search for products ####################################################
    $where_str = " AND ( ";
    $firstItem = true;

    //Search in products_name
    if($searchConfig['SEARCH_IN_PRODUCTS_NAME'] == 1) {
            !$firstItem ? $where_str.=" OR " : false;
            if($searchConfig['SEVERAL_KEYWORDS_AND'] == 1) {
                    $temp_ary = explode(' ', $keyword);
                    $temp_ary2 = array();
                    for ( $i = 0; $i < count($temp_ary); ++$i )
                    {
                            $temp_ary2[] = " pd.products_name LIKE '%" . $temp_ary[$i] . "%' ";
                    }
                    if ( count($temp_ary2) > 0 )
                    {
                            $where_str.= ' ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                    }

                    if ($ent_keyword)
                    {
                            $temp_ary = explode(' ', $ent_keyword);
                            $temp_ary2 = array();
                            for ( $i = 0; $i < count($temp_ary); ++$i )
                            {
                                    $temp_ary2[] = " pd.products_name LIKE '%" . $temp_ary[$i] . "%' ";
                            }
                            if ( count($temp_ary2) > 0 )
                            {
                                    $where_str.= ' OR ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                            }
                    }

            } else {
                    $where_str .= "pd.products_name LIKE '%" . $keyword . "%' ";
                    $where_str .= ($ent_keyword) ? "OR pd.products_name LIKE ('%".$ent_keyword."%') " : '';
            }
            $firstItem=false;
    }

    //Search in products_keywords
    if($searchConfig['SEARCH_IN_PRODUCTS_KEYWORDS'] == 1) {
            !$firstItem ? $where_str.=" OR " : false;
            if($searchConfig['SEVERAL_KEYWORDS_AND'] == 1) {
                    $temp_ary = explode(' ', $keyword);
                    $temp_ary2 = array();
                    for ( $i = 0; $i < count($temp_ary); ++$i )
                    {
                            $temp_ary2[] = " pd.products_keywords LIKE '%" . $temp_ary[$i] . "%' ";
                    }
                    if ( count($temp_ary2) > 0 )
                    {
                            $where_str.= ' ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                    }

                    if ($ent_keyword)
                    {
                            $temp_ary = explode(' ', $ent_keyword);
                            $temp_ary2 = array();
                            for ( $i = 0; $i < count($temp_ary); ++$i )
                            {
                                    $temp_ary2[] = " pd.products_keywords LIKE '%" . $temp_ary[$i] . "%' ";
                            }
                            if ( count($temp_ary2) > 0 )
                            {
                                    $where_str.= ' OR ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                            }
                    }

            } else {
                    $where_str .= "OR pd.products_keywords LIKE '%" . $keyword . "%' ";
                    $where_str .= ($ent_keyword) ? "OR pd.products_keywords LIKE ('%".$ent_keyword."%') " : '';
            }
            $firstItem=false;
    }

    //Search in products_description
    if ($searchConfig['SEARCH_IN_PRODUCTS_DESCRIPTION'] == 1) {
            !$firstItem ? $where_str.=" OR " : false;
            if($searchConfig['SEVERAL_KEYWORDS_AND'] == 1) {
                    $temp_ary = explode(' ', $keyword);
                    $temp_ary2 = array();
                    for ( $i = 0; $i < count($temp_ary); ++$i )
                    {
                            $temp_ary2[] = " pd.products_description LIKE '%" . $temp_ary[$i] . "%' ";
                    }
                    if ( count($temp_ary2) > 0 )
                    {
                            $where_str.= ' ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                    }


                    if ($ent_keyword)
                    {
                            $temp_ary = explode(' ', $ent_keyword);
                            $temp_ary2 = array();
                            for ( $i = 0; $i < count($temp_ary); ++$i )
                            {
                                    $temp_ary2[] = " pd.products_description LIKE '%" . $temp_ary[$i] . "%' ";
                            }
                            if ( count($temp_ary2) > 0 )
                            {
                                    $where_str.= ' OR ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                            }
                    }

            } else {
                    $where_str .= "OR pd.products_description LIKE '%" . $keyword . "%' ";
                    $where_str .= ($ent_keyword) ? "OR pd.products_description LIKE ('%".$ent_keyword."%') " : '';
            }
            $firstItem=false;
    }

    //Search in products_short_description
    if ($searchConfig['SEARCH_IN_PRODUCTS_SHORT_DESCRIPTION'] == 1) {
            !$firstItem ? $where_str.=" OR " : false;
            if($searchConfig['SEVERAL_KEYWORDS_AND'] == 1) {
                    $temp_ary = explode(' ', $keyword);
                    $temp_ary2 = array();
                    for ( $i = 0; $i < count($temp_ary); ++$i )
                    {
                            $temp_ary2[] = " pd.products_short_description LIKE '%" . $temp_ary[$i] . "%' ";
                    }
                    if ( count($temp_ary2) > 0 )
                    {
                            $where_str.= ' ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                    }

                    if ($ent_keyword)
                    {
                            $temp_ary = explode(' ', $ent_keyword);
                            $temp_ary2 = array();
                            for ( $i = 0; $i < count($temp_ary); ++$i )
                            {
                                    $temp_ary2[] = " pd.products_short_description LIKE '%" . $temp_ary[$i] . "%' ";
                            }
                            if ( count($temp_ary2) > 0 )
                            {
                                    $where_str.= ' OR ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                            }
                    }

            } else {
                    $where_str .= "OR pd.products_short_description LIKE '%" . $keyword . "%' ";
                    $where_str .= ($ent_keyword) ? "OR pd.products_short_description LIKE ('%".$ent_keyword."%') " : '';
            }
            $firstItem=false;
    }

    //Search in products_model
    if ($searchConfig['SEARCH_IN_PRODUCTS_MODEL'] == 1) {
            !$firstItem ? $where_str.=" OR " : false;
            if($searchConfig['SEVERAL_KEYWORDS_AND'] == 1) {
                    $temp_ary = explode(' ', $keyword);
                    $temp_ary2 = array();
                    for ( $i = 0; $i < count($temp_ary); ++$i )
                    {
                            $temp_ary2[] = " p.products_model LIKE '%" . $temp_ary[$i] . "%' ";
                    }
                    if ( count($temp_ary2) > 0 )
                    {
                            $where_str.= ' ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                    }

                    if ($ent_keyword)
                    {
                            $temp_ary = explode(' ', $ent_keyword);
                            $temp_ary2 = array();
                            for ( $i = 0; $i < count($temp_ary); ++$i )
                            {
                                    $temp_ary2[] = " p.products_model LIKE '%" . $temp_ary[$i] . "%' ";
                            }
                            if ( count($temp_ary2) > 0 )
                            {
                                    $where_str.= ' OR ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                            }
                    }

            } else {
                    $where_str .= "OR p.products_model LIKE '%" . $keyword . "%' ";
                    $where_str .= ($ent_keyword) ? "OR p.products_model LIKE ('%".$ent_keyword."%') " : '';
            }
            $firstItem=false;
    }

    //Search in products_ean
    if ($searchConfig['SEARCH_IN_PRODUCTS_EAN'] == 1) {
            !$firstItem ? $where_str.=" OR " : false;
            if($searchConfig['SEVERAL_KEYWORDS_AND'] == 1) {
                    $temp_ary = explode(' ', $keyword);
                    $temp_ary2 = array();
                    for ( $i = 0; $i < count($temp_ary); ++$i )
                    {
                            $temp_ary2[] = " p.products_ean LIKE '%" . $temp_ary[$i] . "%' ";
                    }
                    if ( count($temp_ary2) > 0 )
                    {
                            $where_str.= ' ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                    }

                    if ($ent_keyword)
                    {
                            $temp_ary = explode(' ', $ent_keyword);
                            $temp_ary2 = array();
                            for ( $i = 0; $i < count($temp_ary); ++$i )
                            {
                                    $temp_ary2[] = " p.products_ean LIKE '%" . $temp_ary[$i] . "%' ";
                            }
                            if ( count($temp_ary2) > 0 )
                            {
                                    $where_str.= ' OR ( ' . implode(' AND ', $temp_ary2) . ' ) ';
                            }
                    }

            } else {
                    $where_str .= "OR p.products_ean LIKE '%" . $keyword . "%' ";
                    $where_str .= ($ent_keyword) ? "OR p.products_ean LIKE ('%".$ent_keyword."%') " : '';
            }
            $firstItem=false;
    }


    $where_str.=" ) ";

    //fsk18 lock
            if ($_SESSION['customers_status']['customers_fsk18_display'] == '0') {
                    $fsk_lock = " AND p.products_fsk18 != '1' ";
              } else {
                      unset ($fsk_lock);
              }

    //group check
            if (GROUP_CHECK == 'true') {
                    $group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']."=1 ";
              } else {
                      unset ($group_check);
              }

    //Build SQL-Query for products-search
    //BOF web28 - 2011-04-22 - change $where_str to %s
    $sql_str = "
      SELECT
        p.products_id,
        p.products_tax_class_id,
        p.products_price,
        p.products_image,
        pd.products_name,
        pd.products_short_description,
        p2c.categories_id,
        c.categories_status,
        cd.categories_name
      FROM
         "
    . TABLE_PRODUCTS . " p
        LEFT JOIN "
    . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id
        LEFT JOIN "
    . TABLE_PRODUCTS_TO_CATEGORIES . " p2c ON p2c.products_id = pd.products_id
        LEFT JOIN "
    . TABLE_CATEGORIES . " c ON c.categories_id = p2c.categories_id
        LEFT JOIN "
    . TABLE_CATEGORIES_DESCRIPTION . " cd ON c.categories_id = cd.categories_id
      WHERE
      cd.language_id = '"
    .(int)$languages_id."'
      AND
      p.products_status = '1'
      AND
      c.categories_status = '1'
      AND
      pd.language_id = '"
    .(int)$languages_id."'"
      .$fsk_lock.$group_check."%s".$str_group_by."
      ORDER BY cd.categories_name ASC, pd.products_name ASC
      LIMIT 0,"
    .$searchConfig['PRODUCT_RESULT_COUNT'];
      //EOF web28 - 2011-04-22 - change $where_str to %s

    $fetch = xtc_db_query(sprintf($sql_str,$where_str)); //web28 - 2011-04-22 - using sprintf
    $num_rows = mysql_num_rows($fetch);
    if ($num_rows > 0)
    {
      while ($row = xtc_db_fetch_array($fetch)) {
        getProdReturnArray($row,false); //web28 - 2011-04-22 - New function handling -> true: use $text_soundex
      }
    }

    //nothing found? try soundex
    if ($num_rows == 0 && $num_rows_cat == 0 && $searchConfig['SOUNDEX_SEARCH_PRODUCT_NAMES'] == 1){

            $where_str = " AND ( soundex_match('".$keyword."', products_name, ' ') = 1 ) ";

            $fetch = xtc_db_query(sprintf($sql_str,$where_str)); //web28 - 2011-04-22 - using sprintf
            $num_rows = mysql_num_rows($fetch);

      while ($row = xtc_db_fetch_array($fetch)) {
        getProdReturnArray($row,true); //web28 - 2011-04-22 - New function handling -> true: use $text_soundex
      }
    }

    //nothing found? try koelner phonetik
    if ($num_rows == 0 && $num_rows_cat == 0 && $searchConfig['KOELNER_PHONETIK_PRODUCT_NAMES'] == 1){

            $where_str = " AND ( koelner_match('".$keyword."', products_name, ' ') = 1 ) ";

            $fetch = xtc_db_query(sprintf($sql_str,$where_str)); //web28 - 2011-04-22 - using sprintf
            $num_rows = mysql_num_rows($fetch);

      while ($row = xtc_db_fetch_array($fetch)) {
        getProdReturnArray($row,true); //web28 - 2011-04-22 - New function handling -> true: use $text_soundex
      }
    }
    //EOF - Search for products ####################################################

    unset($searchConfig);
    print json_encode($return_arr);


    //BOF - functions ####################################################

    /**
      * change the global $return_arr -> add categorie entries
      * @param Array $row_cat
      * @param String $text_autocomplete
      * @global $searchConfig
      * @global $text_autocomplete
      * @change global $return_arr
    */

    function getCatReturnArray($row_cat,$text_autocomplete) {
      global $searchConfig, $return_arr;

      $str_cat = utf8_encode($row_cat['categories_name']);
      //if string is too long then substr
      if (strlen($str_cat)>$searchConfig['SUBSTRING_COUNT']){
        $str_cat = substr($str_cat, 0, $searchConfig['SUBSTRING_COUNT']) . $searchConfig['SUBSTRING_FINALIZER'];
      }

      $category='';
      if ($searchConfig['GROUP_RESULTS'] == 1){
        $category=utf8_encode($text_autocomplete);
      }

      //append to results array
      //BOF - web28 - 2011-04-18 - NEW categories_link_link
      $return_arr[] = array(
                            'label'     => $str_cat,
                            'link'      => categoriesLink($row_cat['categories_id']),
                            'value'     => $row_cat['categories_id'],
                            'category'  => $category,
                            'desc'      => ''
                           );
      //EOF - web28 - 2011-04-18 - NEW categories_link_link
    }

    /**
      * change the global $return_arr -< add product entries
      * @param Array $row
      * @param Boolean $soundex
      * @global $searchConfig
      * @global $return_arr
      * @global $xtPrice
      * @change global $return_arr
    */

    function getProdReturnArray($row,$text_soundex) {
      global $searchConfig, $return_arr, $xtPrice;

      if($searchConfig['SHOW_CATEGORY_WITH_PRODUCT'] == 1) {
        $str = utf8_encode($row['categories_name'] .' => '. $row['products_name']);
      } else {
        $str = utf8_encode($row['products_name']);
      }

      //if string is too long then substr
      if (strlen($str)>$searchConfig['SUBSTRING_COUNT']){
        $str = substr($str, 0, $searchConfig['SUBSTRING_COUNT']) . $searchConfig['SUBSTRING_FINALIZER'];
      }

      $category='';
      if (!$text_soundex) {
        if ($searchConfig['GROUP_RESULTS'] == 1 && !is_null($row['categories_name']) && strlen($row['categories_name']) > 0){
          $category=utf8_encode($row['categories_name']);
        }
      } else {
        if ($searchConfig['GROUP_RESULTS'] == 1){
          $category=utf8_encode(TEXT_AUTOCOMPLETE_SOUNDEX);
        }
      }

      $desc = '';
      if ($searchConfig['SHOW_PRODUCT_DESC'] == 1) {
        $desc = truncateStr($row['products_short_description']);
      }

      $products_price = '';
      if ($searchConfig['SHOW_PRODUCT_PRICE'] == 1) {
        $products_price = $xtPrice->xtcGetPrice($row['products_id'], $format = true, 1, $row['products_tax_class_id'], $row['products_price'], 1); //functionxtcGetPrice in class xtcprice
      }

      //append to results array
      //BOF - web28 - 2011-04-18 - NEW products_link
      $return_arr[] = array(
                            'label'     => $str,
                            'link'      => productLink($row['products_id'], $row['products_name']),
                            'value'     => $row['products_id'],
                            'category'  => $category,
                            'image'     => productImage($row['products_image']),
                            'desc'      => $desc,
                            'price'     => $products_price['formated']
                           );
      //BOF - web28 - 2011-04-18 - NEW products_link
    }

    /**
      * returns a truncate string by defined lenght $searchConfig['PRODUCT_DESC_MAX_LENGTH']
      * @param String $str
      * @global $searchConfig
      * @return String
    */

    function truncateStr($str) {
      global $searchConfig;
      $str = utf8_encode(strip_tags($str));
      if (strlen($str)>$searchConfig['PRODUCT_DESC_MAX_LENGTH']) {
        $str = substr($str, 0, $searchConfig['PRODUCT_DESC_MAX_LENGTH']) . $searchConfig['SUBSTRING_FINALIZER'];
      }
      return $str;
    }

    /**
      * returns the categories link created by xtc_href_link
      * @param Integer $categories_id
      * @global $searchConfig
      * @return String categories_link
    */

    function categoriesLink($categories_id){
      global $searchConfig;
      $categories_link = xtc_href_link(FILENAME_DEFAULT, 'cPath='.xtc_get_category_path($categories_id), 'NONSSL', false, $searchConfig['USE_SUMA_LINKS']);
      $categories_link = str_replace('&amp;', '&',$categories_link);
      return $categories_link;
    }

    /**
      * returns the product image using the function productImage in class product
      * @param String $image
      * @global $searchConfig
      * @global $product
      * @return String productImage
    */

    function productImage($image){
      global $searchConfig, $product;
      if (!$searchConfig['SHOW_PRODUCT_IMAGE']) {
        return '';
      }
      return $product->productImage($image, 'thumbnail'); //function productImage in class product
    }

    /**
      * returns the product link created by xtc_href_link
      * @param Integer $products_id
      * @param String $products_name
      * @global $searchConfig
      * @return String productLink
    */

    function productLink($products_id, $products_name){
      global $searchConfig;
      $products_link = xtc_href_link(FILENAME_PRODUCT_INFO, xtc_product_link($products_id, $products_name), 'NONSSL', false, $searchConfig['USE_SUMA_LINKS']);
      $products_link = str_replace('&amp;', '&',$products_link);
      return $products_link;
    }

    //BOF - functions ####################################################

    ?>

    Danke für Deine Mühe!

    Beste Grüße,
    Wayne

    h-h-h

    • modified Team
    • Beiträge: 4.562
    Code: PHP  [Auswählen]
    {php}
    echo '<pre>'.$_SESSION['languages_id'].'</pre>';
    {/php}

    Code: XML  [Auswählen]
    <pre>{$smarty.session.languages_id}</pre>

    @Wayne: hast du Cookies im Browser aktiv?

    Viele Grüße

    h-h-h

    EDIT:
    Code: XML  [Auswählen]
    <pre>{$smarty.session.languages_id|intval}</pre>

    noRiddle (revilonetz)

    • Experte
    • Beiträge: 13.990
    • Geschlecht:
    Ist doch egal h-h-h, du alter Klugsch...  :-D
    Wir wollten doch nur wissen ob $languages_id bekannt ist und richtig ausgegeben wird.

    @WayneTsun
    Ich sehe da erstmal nur einen Fehler.
    An dieser Stelle:
    Code: PHP  [Auswählen]
    $sql_str_cat = "SELECT cd.categories_id,
                             cd.categories_name
                        FROM "
    .TABLE_CATEGORIES." c
                  INNER JOIN "
    .TABLE_CATEGORIES_DESCRIPTION." cd
                          ON c.categories_id = cd.categories_id
                       WHERE cd.language_id = '"
    .(int)$languages_id."'
                       "
    .$group_check."
                         AND c.categories_status = '1'
                             %s
                    ORDER BY cd.categories_name
                       LIMIT 0,"
    .$searchConfig['CATEGORY_RESULT_COUNT'];

    muß es wohl heißen:
    Code: PHP  [Auswählen]
    ".$group_check_c."

    Ansonsten:
    • Testweise vielleicht auch mal vorübergehend im Ordner /includes/application_top.php das error_reporting(E_ALL & ~E_NOTICE); in error_reporting(E_ALL); ändern und schauen ob Fehler-Notices kommen.
    • Testweise mal das (int) vor $languages_id weglassen.
    • Testweise mal die Definition von $languages_id so abändern
      $languages_id = (int)$_SESSION['languages_id'];
      und bei $languages_id das (int) dann weglassen.
    • *EDIT*
      Und mal den vorangegangenen Test wiederholen nur diesmal so:
    Code: PHP  [Auswählen]
        {php}
        echo '<pre>'.(int)$_SESSION['languages_id'].'</pre>';
        {/php}

    Gruß,
    noRiddle

    WayneTsun

    • Fördermitglied
    • Beiträge: 1.082
    • Geschlecht:
    @h-h-h
    Ja, Cookies sind an.

    @noRiddle

    $group_check.c hatte ich doch schon, oder wo meintest Du?

    Habe alle (int) Varianten ausprobiert. Leider ohne positivem Ergebnis.

    language_id wird auch mit dem geänderten Code in der box_search korrekt ausgegeben.

    Leider auch keine error_reportings.

    Vielen Dank für Eure Hilfe!

    Beste Grüße,
    Wayne
    Modulshop - Eine große Auswahl an neuen und hilfreichen Modulen für die modified eCommerce Shopsoftware
    1 Antworten
    2713 Aufrufe
    10. April 2012, 01:32:40 von h-h-h
    2 Antworten
    3256 Aufrufe
    12. April 2012, 09:29:29 von werresal
    2 Antworten
    2701 Aufrufe
    29. Mai 2017, 11:36:33 von monnecke
    18 Antworten
    13169 Aufrufe
    21. Dezember 2010, 11:45:08 von plasticman
               
    anything