Suche nach Hersteller

Hallo :slight_smile:

Kann mir jemand bitte bitte helfen? Ich versuche die Suche so einzustellen, dass man im inputfeld nach hersteller suchen kann, (manufacturer) …

Hat jemand eine Idee wo und wie ich das erweitern kann? Geht das im Template oder vielleicht in der oxsearch.php search.php?

DANKEschön!

“oxmanufacturers” eintragen unter Admin -> Stammdaten -> Grundeinstellungen -> Einstellungen -> Suche

(ohne Garantie, habs noch nicht selbst versucht)

Hi und danke fuer die schnellle Antwort.

Hat leider nicht funktioniert, muss ich da nicht was im Code aendern weil wie oxmanufacturers nicht in oxarticles ist?

[QUOTE=Rotkaeqpchen;54665]Hi und danke fuer die schnellle Antwort.

Hat leider nicht funktioniert, muss ich da nicht was im Code aendern weil wie oxmanufacturers nicht in oxarticles ist?[/QUOTE]

Jupp, so sieht es aus.
Am Besten mit einem Left Join und einem kleinen Modul.

Gruß Joscha

Vielen Dank für die Antwort, so etwas ähnliches hat mir mein Kumpel auch gesagt, nur leider hab ich von SQL Abfragen fast keine Ahnung und wüsste nicht einmal wo diese hin sollte.

Für eine kleine Hilfestellung wäre ich sehr dankbar, ich bin leider nur Designer und nur ganz amateurhaft programmierer, ist ein Privatprojekt :slight_smile:

[QUOTE=Rotkaeqpchen;54667]Vielen Dank für die Antwort, so etwas ähnliches hat mir mein Kumpel auch gesagt, nur leider hab ich von SQL Abfragen fast keine Ahnung und wüsste nicht einmal wo diese hin sollte.

Für eine kleine Hilfestellung wäre ich sehr dankbar, ich bin leider nur Designer und nur ganz amateurhaft programmierer, ist ein Privatprojekt :)[/QUOTE]

Ich geh mal davon aus, dass es eine CE ist? Welche Version denn?

Gruß Joscha

Es ist die CE 4.4.5 noch, habe durch einpaar Anpassungen leider die Updatefähigkeit verloren, werde das aber in Zukunft noch korrigieren, ein Freund hat mir erklärt (so halb) wie man aus Modifikationen ein ordentliches Modul erstellt. :slight_smile:

[QUOTE=Rotkaeqpchen;54669]Es ist die CE 4.4.5 noch, habe durch einpaar Anpassungen leider die Updatefähigkeit verloren, werde das aber in Zukunft noch korrigieren, ein Freund hat mir erklärt (so halb) wie man aus Modifikationen ein ordentliches Modul erstellt. :)[/QUOTE]

Hallo,

hab da mal eben einen Blick rein geworfen:

Man müsste mit einem Modul die Funktionen _getSearchSelect() und _getWhere in oxSearch erweitern.

Das Ding ist ein ziemliches Monster!

Hier mal der Ansatz, der bei mir zwar das richtige Ergebnis liefert, aber noch den falschen Titel für die Artikel:


<?php


class marm_searchmanufacturers_oxsearch extends marm_searchmanufacturers_oxsearch_parent {


    protected function _getSearchSelect( $sSearchParamForQuery = false, $sInitialSearchCat = false, $sInitialSearchVendor = false, $sInitialSearchManufacturer = false, $sSortBy = false)
    {
        $oDb = oxDb::getDb();

        // performance
        if ( $sInitialSearchCat ) {
            // lets search this category - is no such category - skip all other code
            $oCategory = oxNew( 'oxcategory' );
            $sCatTable = $oCategory->getViewName();

            $sQ  = "select 1 from $sCatTable where $sCatTable.oxid = ".$oDb->quote( $sInitialSearchCat )." ";
            $sQ .= "and ".$oCategory->getSqlActiveSnippet();
            if ( !$oDb->getOne( $sQ ) ) {
                return;
            }
        }

        // performance:
        if ( $sInitialSearchVendor ) {
            // lets search this vendor - if no such vendor - skip all other code
            $oVendor   = oxNew( 'oxvendor' );
            $sVndTable = $oVendor->getViewName();

            $sQ  = "select 1 from $sVndTable where $sVndTable.oxid = ".$oDb->quote( $sInitialSearchVendor )." ";
            $sQ .= "and ".$oVendor->getSqlActiveSnippet();
            if ( !$oDb->getOne( $sQ ) ) {
                return;
            }
        }

        // performance:
        if ( $sInitialSearchManufacturer ) {
            // lets search this Manufacturer - if no such Manufacturer - skip all other code
            $oManufacturer   = oxNew( 'oxmanufacturer' );
            $sManTable = $oManufacturer->getViewName();

            $sQ  = "select 1 from $sManTable where $sManTable.oxid = ".$oDb->quote( $sInitialSearchManufacturer )." ";
            $sQ .= "and ".$oManufacturer->getSqlActiveSnippet();
            if ( !$oDb->getOne( $sQ ) ) {
                return;
            }
        }

        $sWhere = null;

        if ( $sSearchParamForQuery ) {
            $sWhere = $this->_getWhere( $sSearchParamForQuery );
        } elseif ( !$sInitialSearchCat && !$sInitialSearchVendor && !$sInitialSearchManufacturer ) {
            //no search string
            return null;
        }

        $oArticle = oxNew( 'oxarticle' );
        $sArticleTable = $oArticle->getViewName();
        $sO2CView      = getViewName( 'oxobject2category' );

        $sSelectFields = $oArticle->getSelectFields();

        // longdesc field now is kept on different table
        $sDescJoin  = '';
        if ( is_array( $aSearchCols = $this->getConfig()->getConfigParam( 'aSearchCols' ) ) ) {
            if ( in_array( 'oxlongdesc', $aSearchCols ) || in_array( 'oxtags', $aSearchCols ) ) {
                $sDescView  = getViewName( 'oxartextends' );
                $sDescJoin  = " LEFT JOIN {$sDescView} ON {$sArticleTable}.oxid={$sDescView}.oxid ";
            }
        }

        //select articles
        $sSelect = "select {$sSelectFields} , oxmanufacturers.oxtitle, oxmanufacturers.oxshortdesc from {$sArticleTable} {$sDescJoin} LEFT JOIN oxmanufacturers ON oxarticles.oxmanufacturerid=oxmanufacturers.oxid where ";

        // must be additional conditions in select if searching in category
        if ( $sInitialSearchCat ) {
            $sCatView = getViewName( 'oxcategories' );
            $sInitialSearchCatQuoted = $oDb->quote( $sInitialSearchCat );
            $sSelectCat  = "select oxid from {$sCatView} where oxid =  $sInitialSearchCatQuoted and (oxpricefrom != '0' or oxpriceto != 0)";
            if ( $oDb->getOne($sSelectCat) ) {
                $sSelect = "select {$sSelectFields} from {$sArticleTable} $sDescJoin " .
                           "where {$sArticleTable}.oxid in ( select {$sArticleTable}.oxid as id from {$sArticleTable}, {$sO2CView} as oxobject2category, {$sCatView} as oxcategories " .
                           "where (oxobject2category.oxcatnid=$sInitialSearchCatQuoted and oxobject2category.oxobjectid={$sArticleTable}.oxid) or (oxcategories.oxid=$sInitialSearchCatQuoted and {$sArticleTable}.oxprice >= oxcategories.oxpricefrom and
                            {$sArticleTable}.oxprice <= oxcategories.oxpriceto )) and ";
            } else {
                $sSelect = "select {$sSelectFields} from {$sO2CView} as
                            oxobject2category, {$sArticleTable} {$sDescJoin} where oxobject2category.oxcatnid=$sInitialSearchCatQuoted and
                            oxobject2category.oxobjectid={$sArticleTable}.oxid and ";
            }
        }

        $sSelect .= $oArticle->getSqlActiveSnippet();
        $sSelect .= " and {$sArticleTable}.oxparentid = '' and {$sArticleTable}.oxissearch = 1 ";

        if ( $sInitialSearchVendor ) {
            $sSelect .= " and {$sArticleTable}.oxvendorid = " . $oDb->quote( $sInitialSearchVendor ) . " ";
        }

        if ( $sInitialSearchManufacturer ) {
            $sSelect .= " and {$sArticleTable}.oxmanufacturerid = " . $oDb->quote( $sInitialSearchManufacturer ) . " ";
        }

        $sSelect .= $sWhere;

        if ( $sSortBy ) {
            $sSelect .= " order by {$sSortBy} ";
        }

        echo $sSelect;
        return $sSelect;
    }
	
	
	 protected function _getWhere( $sSearchString )
    {
        $oDb = oxDb::getDb();
        $myConfig = $this->getConfig();
        $blSep    = false;
        $sArticleTable = getViewName( 'oxarticles' );

        $aSearchCols = $myConfig->getConfigParam( 'aSearchCols' );
        if ( !(is_array( $aSearchCols ) && count( $aSearchCols ) ) ) {
            return '';
        }

        $oTempArticle = oxNew( 'oxarticle' );
        $sSearchSep   = $myConfig->getConfigParam( 'blSearchUseAND' )?'and ':'or ';
        $aSearch  = explode( ' ', $sSearchString );
        $sSearch  = ' and ( ';
        $myUtilsString = oxUtilsString::getInstance();
        $oLang = oxLang::getInstance();

        foreach ( $aSearch as $sSearchString ) {

            if ( !strlen( $sSearchString ) ) {
                continue;
            }

            if ( $blSep ) {
                $sSearch .= $sSearchSep;
            }

            $blSep2 = false;
            $sSearch  .= '( ';

            foreach ( $aSearchCols as $sField ) {

                if ( $blSep2 ) {
                    $sSearch  .= ' or ';
                }

                $sLanguage = '';
                if ( $this->_iLanguage && $oTempArticle->isMultilingualField( $sField ) ) {
                    $sLanguage = $oLang->getLanguageTag( $this->_iLanguage );
                }

                // as long description now is on different table table must differ
                if ( $sField == 'oxlongdesc' || $sField == 'oxtags' ) {
                    $sSearchField = getViewName( 'oxartextends' ).".{$sField}{$sLanguage}";
                } else {
                    $sSearchField = "{$sArticleTable}.{$sField}{$sLanguage}";
                }

                $sSearch .= " {$sSearchField} like ".$oDb->quote( "%$sSearchString%" );

                // special chars ?
                if ( ( $sUml = $myUtilsString->prepareStrForSearch( $sSearchString ) ) ) {
                    $sSearch  .= " or {$sSearchField} like ".$oDb->quote( "%$sUml%" );
                }

                $blSep2 = true;
            }
			$sSearch .= 'or oxmanufacturers.oxtitle like '.$oDb->quote( "%$sSearchString%" );
			$sSearch .= ' or oxmanufacturers.oxshortdesc like '.$oDb->quote( "%$sSearchString%" );
            $sSearch  .= ' ) ';

            $blSep = true;
        }

        $sSearch .= ' ) ';
        return $sSearch;
    }

}

Das ganze liegt bei mir in


modules/marm_searchmanufacturers/marm_searchmanufacturers_oxsearch.php

und kann als Modul integriert werden


oxsearch => marm_searchmanufacturers/marm_searchmanufacturers_oxsearch

Hilft dir das weiter?

Gruß Joscha

Das ganz egeht sicher auch eleganter und mit weniger Copy+Paste, aber nicht mehr auf die Nacht.

Gruß Joscha

Wow! Vielen Dank schon mal ;))) Ich werde das morgen mal einbauen und mich melden.

vielen dank fuer die unterstuetzung!!

einen hab ich noch

Zeile 75 im Minimodul ändern zu


        //select articles
        $sSelect = "select oxmanufacturers.oxtitle, oxmanufacturers.oxshortdesc, {$sSelectFields}  from {$sArticleTable} {$sDescJoin} LEFT JOIN oxmanufacturers ON oxarticles.oxmanufacturerid=oxmanufacturers.oxid where ";

dann passts auch mit dem Titel wieder.

Gute Nacht.

Hi und vielen vielen Dank, das freut mich echt total, dass du mir da so hilfst :slight_smile:

Ich bau das nachher ein und sag Bescheid obs funktioniert.

Hi, habe es eingebaut und als Modul hinzugefügt.

Leider funktioniert es nicht, die Suchabfrage liefert keine Treffer und am oberen Bildrand erscheint eine Meldung:

select oxmanufacturers.oxtitle, oxmanufacturers.oxshortdesc, oxarticles.oxid from oxarticles LEFT JOIN oxartextends ON oxarticles.oxid=oxartextends.oxid LEFT JOIN oxmanufacturers ON oxarticles.oxmanufacturerid=oxmanufacturers.oxid where ( oxarticles.oxactive = 1 and ( oxarticles.oxstockflag != 2 or ( oxarticles.oxstock + oxarticles.oxvarstock ) > 0 ) and IF( oxarticles.oxvarcount = 0, 1, ( select 1 from oxarticles as art where art.oxparentid=oxarticles.oxid and ( art.oxactive = 1 ) and ( art.oxstockflag != 2 or art.oxstock > 0 ) limit 1 ) ) ) and oxarticles.oxparentid = ‘’ and oxarticles.oxissearch = 1 and ( ( oxarticles.oxtitle like ‘%santa%’ or oxarticles.oxshortdesc like ‘%santa%’ or oxarticles.oxsearchkeys like ‘%santa%’ or oxarticles.oxartnum like ‘%santa%’ or oxartextends.oxtags like ‘%santa%’ or oxartextends.oxlongdesc like ‘%santa%’ or oxarticles.oxmanufacturers like '%santa%'or oxmanufacturers.oxtitle like ‘%santa%’ or oxmanufacturers.oxshortdesc like ‘%santa%’ ) )


EDIT:

Hatte noch die oxmanufacturers in der Sucheinstellung drin, jetzt funktionierts, nur am oberen Bildrand gibts trotzdem die Abfrage im Klartext :slight_smile:

select oxmanufacturers.oxtitle, oxmanufacturers.oxshortdesc, oxarticles.oxid from oxarticles LEFT JOIN oxartextends ON oxarticles.oxid=oxartextends.oxid LEFT JOIN oxmanufacturers ON oxarticles.oxmanufacturerid=oxmanufacturers.oxid where ( oxarticles.oxactive = 1 and ( oxarticles.oxstockflag != 2 or ( oxarticles.oxstock + oxarticles.oxvarstock ) > 0 ) and IF( oxarticles.oxvarcount = 0, 1, ( select 1 from oxarticles as art where art.oxparentid=oxarticles.oxid and ( art.oxactive = 1 ) and ( art.oxstockflag != 2 or art.oxstock > 0 ) limit 1 ) ) ) and oxarticles.oxparentid = ‘’ and oxarticles.oxissearch = 1 and ( ( oxarticles.oxtitle like ‘%santa%’ or oxarticles.oxshortdesc like ‘%santa%’ or oxarticles.oxsearchkeys like ‘%santa%’ or oxarticles.oxartnum like ‘%santa%’ or oxartextends.oxtags like ‘%santa%’ or oxartextends.oxlongdesc like '%santa%'or oxmanufacturers.oxtitle like ‘%santa%’ or oxmanufacturers.oxshortdesc like ‘%santa%’ ) ) select oxmanufacturers.oxtitle, oxmanufacturers.oxshortdesc, oxarticles.oxid from oxarticles LEFT JOIN oxartextends ON oxarticles.oxid=oxartextends.oxid LEFT JOIN oxmanufacturers ON oxarticles.oxmanufacturerid=oxmanufacturers.oxid where ( oxarticles.oxactive = 1 and ( oxarticles.oxstockflag != 2 or ( oxarticles.oxstock + oxarticles.oxvarstock ) > 0 ) and IF( oxarticles.oxvarcount = 0, 1, ( select 1 from oxarticles as art where art.oxparentid=oxarticles.oxid and ( art.oxactive = 1 ) and ( art.oxstockflag != 2 or art.oxstock > 0 ) limit 1 ) ) ) and oxarticles.oxparentid = ‘’ and oxarticles.oxissearch = 1 and ( ( oxarticles.oxtitle like ‘%santa%’ or oxarticles.oxshortdesc like ‘%santa%’ or oxarticles.oxsearchkeys like ‘%santa%’ or oxarticles.oxartnum like ‘%santa%’ or oxartextends.oxtags like ‘%santa%’ or oxartextends.oxlongdesc like '%santa%'or oxmanufacturers.oxtitle like ‘%santa%’ or oxmanufacturers.oxshortdesc like ‘%santa%’ ) )

Außerdem werden die die Produkttitel mit dem Herstellernamen ersetzt in den Suchergebnissen :smiley:

[QUOTE=Rotkaeqpchen;54692]Hi, habe es eingebaut und als Modul hinzugefügt.

Leider funktioniert es nicht, die Suchabfrage liefert keine Treffer und am oberen Bildrand erscheint eine Meldung:
[B]
EDIT: [/B]

Hatte noch die oxmanufacturers in der Sucheinstellung drin, jetzt funktionierts, nur am oberen Bildrand gibts trotzdem die Abfrage im Klartext :slight_smile:
[/QUOTE]

Für die Meldung musst du das


echo ...

natürlich noch entfernen. Das war nur zum Entwickeln um dir zu Zeigen, wie der Query aussieht.

[QUOTE=Rotkaeqpchen;54692]
Außerdem werden die die Produkttitel mit dem Herstellernamen ersetzt in den Suchergebnissen :D[/QUOTE]

Siehe meinen Nachtrag oben. Zeile 75 musst du noch ändern.

Gruß Joscha

Super! Danke! Das meinte ich mit amateurhafter Programmierer (eigentlich bin ich überhaupt gar keiner) :smiley:

Habe Zeile 75 ersetzt, jetzt werden als Produkttitel immernoch der Herstellertitel angezeigt.

das Verzeichnis /tmp leeren und evtl. den Browsercache auch

Hat leider nicht geholfen, habe bei jedem Schritt den tmp Ordner geleert :slight_smile:

$sSelect = "select oxmanufacturers.oxtitle, oxmanufacturers.oxshortdesc, {$sSelectFields}  from {$sArticleTable} {$sDescJoin} LEFT JOIN oxmanufacturers ON oxarticles.oxmanufacturerid=oxmanufacturers.oxid where ";  

Was könnte daran falsch sein… hm…

Juhu, habs rausgefunden (hoffe ich) :slight_smile:

$sSelect = "select oxarticles.oxtitle, oxarticles.oxshortdesc, {$sSelectFields}  from {$sArticleTable} {$sDescJoin} LEFT JOIN oxmanufacturers ON oxarticles.oxmanufacturerid=oxmanufacturers.oxid where ";  

Ich danke euch ganz ganz herzlich für die Hilfe und jkrug für die Bereitstellung des Moduls!

[B]DANKE[/B]

[QUOTE=Rotkaeqpchen;54706]Juhu, habs rausgefunden (hoffe ich) :slight_smile:

$sSelect = "select oxarticles.oxtitle, oxarticles.oxshortdesc, {$sSelectFields}  from {$sArticleTable} {$sDescJoin} LEFT JOIN oxmanufacturers ON oxarticles.oxmanufacturerid=oxmanufacturers.oxid where ";  

Ich danke euch ganz ganz herzlich für die Hilfe und jkrug für die Bereitstellung des Moduls!

[B]DANKE[/B][/QUOTE]

Ich Depp! Sorry. Mein Fehler. So stimmts:

$sSelect = "select {$sSelectFields}  from {$sArticleTable} {$sDescJoin} LEFT JOIN oxmanufacturers ON oxarticles.oxmanufacturerid=oxmanufacturers.oxid where ";  

Gruß Joscha

Du NICHT DEPP, du bist mein Held :slight_smile:

Dankeschön für die Hilfe!