Skip to content
This repository was archived by the owner on Feb 27, 2024. It is now read-only.

Commit 279e060

Browse files
committed
Fix #52
1 parent 907186e commit 279e060

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

src/AmazonProductInfo.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function setSKUs($s)
7070
$this->resetSKUs();
7171
$i = 1;
7272
foreach ($s as $x) {
73-
$this->options['SellerSKUList.SellerSKU.'.$i] = $x;
73+
$this->options['SellerSKUList.SellerSKU.' . $i] = $x;
7474
$i++;
7575
}
7676
} else {
@@ -116,7 +116,7 @@ public function setASINs($s)
116116
$this->resetASINs();
117117
$i = 1;
118118
foreach ($s as $x) {
119-
$this->options['ASINList.ASIN.'.$i] = $x;
119+
$this->options['ASINList.ASIN.' . $i] = $x;
120120
$i++;
121121
}
122122
} else {
@@ -203,7 +203,7 @@ public function fetchCompetitivePricing()
203203

204204
$this->prepareCompetitive();
205205

206-
$url = $this->urlbase.$this->urlbranch;
206+
$url = $this->urlbase . $this->urlbranch;
207207

208208
$query = $this->genQuery();
209209

@@ -273,7 +273,7 @@ public function fetchLowestOffer()
273273

274274
$this->prepareLowest();
275275

276-
$url = $this->urlbase.$this->urlbranch;
276+
$url = $this->urlbase . $this->urlbranch;
277277

278278
$query = $this->genQuery();
279279

@@ -338,7 +338,7 @@ public function fetchMyPrice()
338338

339339
$this->prepareMyPrice();
340340

341-
$url = $this->urlbase.$this->urlbranch;
341+
$url = $this->urlbase . $this->urlbranch;
342342

343343
$query = $this->genQuery();
344344

@@ -394,19 +394,16 @@ protected function prepareMyPrice()
394394
*/
395395
public function fetchCategories()
396396
{
397-
if (! array_key_exists('SellerSKUList.SellerSKU.1', $this->options) && ! array_key_exists(
398-
'ASINList.ASIN.1',
399-
$this->options
400-
)
401-
) {
397+
if (! array_key_exists('SellerSKUList.SellerSKU.1', $this->options) &&
398+
! array_key_exists('ASINList.ASIN.1', $this->options)) {
402399
$this->log('Product IDs must be set in order to look them up!', 'Warning');
403400

404401
return false;
405402
}
406403

407404
$this->prepareCategories();
408405

409-
$url = $this->urlbase.$this->urlbranch;
406+
$url = $this->urlbase . $this->urlbranch;
410407

411408
$query = $this->genQuery();
412409

@@ -448,6 +445,7 @@ protected function prepareCategories()
448445
} else {
449446
if (array_key_exists('ASINList.ASIN.1', $this->options)) {
450447
$this->options['Action'] = 'GetProductCategoriesForASIN';
448+
$this->options['ASIN'] = $this->options['ASINList.ASIN.1'];
451449
$this->resetSKUs();
452450
}
453451
}
@@ -471,7 +469,7 @@ public function fetchMatchingProduct()
471469

472470
$this->prepareMatchingProduct();
473471

474-
$url = $this->urlbase.$this->urlbranch;
472+
$url = $this->urlbase . $this->urlbranch;
475473

476474
$query = $this->genQuery();
477475

tests/classes/AmazonProductInfoTest.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,15 @@ public function testFetchCategories()
227227
resetLog();
228228
$this->object->setMock(true, 'fetchCategories.xml');
229229
$this->assertFalse($this->object->fetchCategories()); //no IDs yet
230+
231+
// Test ASINs
232+
$this->object->setASINs('ASINTEST');
233+
$this->assertNull($this->object->fetchCategories());
234+
$o = $this->object->getOptions();
235+
$this->assertEquals('GetProductCategoriesForASIN', $o['Action']);
236+
$this->assertEquals('ASINTEST', $o['ASIN']);
237+
238+
// Test SKUs
230239
$this->object->setSKUs('789');
231240
$this->assertNull($this->object->fetchCategories());
232241
$o = $this->object->getOptions();
@@ -250,7 +259,8 @@ public function testGetProductCategories($o)
250259
$list = $o->getProduct(null);
251260
$this->assertIsArray($list);
252261
$this->assertArrayHasKey(0, $list);
253-
$this->assertArrayNotHasKey(1, $list);
262+
$this->assertArrayHasKey(1, $list);
263+
$this->assertArrayNotHasKey(2, $list);
254264
$this->assertEquals($product, $list[0]);
255265

256266
$default = $o->getProduct();
@@ -308,4 +318,4 @@ public function testGetMatchingProduct($o)
308318
}
309319
}
310320

311-
require_once __DIR__.'/../helperFunctions.php';
321+
require_once __DIR__ . '/../helperFunctions.php';

0 commit comments

Comments
 (0)