Affilinet WebServices: Suche nach EAN geht nicht

IKaRuS1978

Neues Mitglied
Hallo zusammen,

ich beschäftige mich gerade mit den Affilinet Webservices, dort insbesondere mit dem direkten Abruf von Produktdaten.

Wenn ich hier nun den Code von Affilinet nehme:

// Set webservice endpoint (JSON)
$service = "https://product-api.affili.net/V3/productservice.svc/JSON/SearchProducts";

// If you want to get the response in XML use the following service url
//$serviceXML = "https://product-api.affili.net/V3/productservice.svc/XML/SearchProducts";

// Set credentials
$params['PublisherId'] = '****'; // your publisher ID
$params['Password'] = '****'; // your product web services password

// Narrow down results to specific Shops (optional)
$params['ShopIds'] = '2071'; // enter one or more shop Ids as comma separated list. You can use "GetShopList" to receive Shop Ids
$params['ShopIdMode'] = 'Include';

/**
* Narrow down by Query, CategoryIds or FilterQueries (on of the three must be set)
*
* Query
* Use search operators AND, OR, NOT (in capital letters) for better results
* Use "" for an exact match
* Use () to group expressions
* Use wildcard * for suffix matching, e.g. 'bott*' will match bottle or bottom
* Example: "apple ipod" ((touch OR classic) NOT nano) AND "32 GB"
*/
$params['Query'] = 'battlefront'; //

/**
* CategoryIds
* The Ids of the categories you wish to restrict the search on. Whether the Ids are to be interpreted as shop categories
* or as affilinet categories can be specified by using the parameter "UseAffilinetCategories".
* You can receive shop categories using "GetCategoryList".
*/
$params['CategoryIds'] = '';
$params['UseAffilinetCategories'] = 'true';
$params['ExcludeSubCategories'] = 'false';

/**
* Filter Queries (FQ)
* With the FilterQuery functionality, you can restrict the search results to those products that have a certain value (e.g. "Sony") in a certain data field (e.g. "Brand"). You can define up to 15 FilterQueries at the same time.
* The fields and values must be URL encoded.
*/
$param['FQ'] = urlencode('fq=DataField:EAN');

/**
* Facet fields
* With this parameter, you can specify, what facets shall be created out of the search results (e.g. "Brand", "ShopId",
* "AffilinetCategoryPath" or "Property_Size"). See PDF documentation for a full list.
*/
$params['FacetFields'] = 'ShopId,ShopName,EAN';
$params['FacetValueLimit'] = 5;

// Page settings
$params['CurrentPage'] = 1;
$params['PageSize'] = 20;
$params['SortBy'] = 'Score';
$params['SortOrder'] = 'descending';

// Set further parameters
$params['ImageScales'] = 'Image90,Image180';
$params['LogoScales'] = 'Logo90,Logo150';
$params['WithImageOnly'] = 'true';
$params['MinimumPrice'] = 0;
$params['MaximumPrice'] = 0;

// Put together request
$request = $service . "?" . http_build_query($params);

// Get response
$response = file_get_contents($request, true);

/*
Please note: the JSON output begins with a byte order mark (BOM).
If you run into problems while parsing the JSON response, try removing the BOM first.
*/
if(substr($response,0,3) == pack("CCC", 0xEF,0xBB,0xBF)) {
$response = substr($response,3);
}

// Show response
//print_r($response);


Dieser Code wirft Ergebnisse zum Thema "Battlefront" aus...als JSON String.

So weit so gut....Script an sich funktioniert.

Nur wenn ich jetzt statt nach dem Titel ("Battlefront") nach einer EAN suche, bekomme ich kein Ergebnis.

Wenn ich aber direkt auf der Homepage des Advertisers nach der EAN suche, hab ich sofort einen Treffer.

Wenn ich mir die Daten aus dem JSON-Response mit o.g. Code ansehe, wird die EAN auch mitgeliefert.

Nur der direkte Abruf mit EAN als Suche...das klappt nicht.

Hat jemand eine Idee dazu?

 
Zuletzt bearbeitet von einem Moderator:
Hallo,

wo im Code siehst du,  dass die EAN mitgeliefert wird? Du hast du nur "battlefield" für  die Suche definiert, oder?

 
Hier zum Beispiel... (Screenshot)

ich kann auch, wenn ich den Suchbegriff eingebe, sämtliche Daten, inkl. der EAN, ausgeben lassen am Bildschirm.

will es aber umgekehrt haben. Nicht den Titel suchen und die EAN raus kriegen. Die EANs der ganzen Artikel hab ich. Um immer den gleichen Artikel zu haben und nicht verschiedene Editionen oder so, will ich über die EAN suchen.

image.png

 
Also ich hab jetzt wieder stundenlang hin und her probiert.

Entweder funktioniert da was nicht, oder ich bin zu blöd, die API-Dokumentation zu begreifen.

Wenn ich als Query "Battlefront" angebe, bekomme ich alle möglichen Ergebnisse, die Battlefront betreffen,

Wenn ich dann als FilterQuery die EAN setze, wird das rein gar nicht berücksichtigt. Es werden die gleichen Ergebnisse, wie vorher ausgegeben.

Ich bin mir aber auch nicht sicher, wie ich den Filter richtig setze. Ich habe diverse Dinge probiert.

fq=EAN:05035226112560

fq=DataField:05035226112560

fq=DataField:EAN,fq=EAN:05035226112560

usw.

Immer die gleichen Ergenisse, den Suchbegriff "Battlefront" betreffend.

In der Dokumentation steht, dass ein Query Begriff nicht unbedingt erforderlich ist. Allerdings muss mindestens ein Feld (Query, CategoryId oder FilterQuery) gesetzt sein.

Lasse ich den FQ wie oben angegeben drin, aber setze gar keinen Query String, bekomme ich nur eine Fehlermeldung:

Warning: file_get_contents(https://product-api.affili.net/V3/productservice.svc/JSON/SearchProducts?PublisherId=7******&Password=*******&LogoScale=Logo150&CurrentPage=1&PageSize=20&UpdatedAfter=2016-05-17T04%3A52%3A08%2B00%3A00&ShopIds=%24shoplist%5BShopId%5D&ShopIdMode=Include&Query=&CategoryIds=&UseAffilinetCategories=true&ExcludeSubCategories=false&FacetFields=&FacetValueLimit=5&SortBy=Score&SortOrder=descending&ImageScales=Image90%2CImage180&LogoScales=Logo90%2CLogo150&WithImageOnly=true&MinimumPrice=0&MaximumPrice=0): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /customers/7/e/b/****.de/httpd.www/*****.php on line 112 Warning: Invalid argument supplied for foreach() in /customers/7/e/b/*****.de/httpd.www/*****.php on line 126
Setze ich als Query die EAN und lasse den FilterQuery leer, bekomme ich ein leeres Ergebnis.

Ich bin echt am verzweifeln.

 
Zurück
Oben