Skip to content

Commit a333b5c

Browse files
authored
Merge pull request #19 from justbetter/feature/fixes
Small fixes
2 parents f8261ae + 622b14d commit a333b5c

File tree

5 files changed

+7
-2
lines changed

5 files changed

+7
-2
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ After you've created and configured the repository you have to set it in your co
171171
return [
172172
'repository' => \App\Integrations\MagentoStock\MyStockRepository::class,
173173
];
174-
175174
```
176175

177176
### Usage

src/Actions/ProcessStocks.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function process(): void
1818
$repository = BaseRepository::resolve();
1919

2020
Stock::query()
21+
->where('sync', '=', true)
2122
->where('retrieve', '=', true)
2223
->select(['sku'])
2324
->take($repository->retrieveLimit())
@@ -26,6 +27,7 @@ public function process(): void
2627

2728
if (config('magento-stock.async')) {
2829
$stocks = Stock::query()
30+
->where('sync', '=', true)
2931
->where('update', '=', true)
3032
->whereHas('product', function (Builder $query): void {
3133
$query->where('exists_in_magento', '=', true);
@@ -37,6 +39,7 @@ public function process(): void
3739
UpdateStockAsyncJob::dispatch($stocks);
3840
} else {
3941
Stock::query()
42+
->where('sync', '=', true)
4043
->where('update', '=', true)
4144
->select(['id', 'sku'])
4245
->take($repository->updateLimit())

src/Models/Stock.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function failed(): void
8080
if (! $shouldRetry) {
8181
$this->update = false;
8282
$this->retrieve = false;
83+
$this->fail_count = 0;
8384
}
8485

8586
$this->save();

src/Repositories/Repository.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public function skus(?Carbon $from = null): Collection
2020
/** @var Collection<int, string> $skus */
2121
$skus = MagentoProduct::query()
2222
->where('exists_in_magento', '=', true)
23+
->select(['sku'])
24+
->distinct()
2325
->pluck('sku');
2426

2527
return $skus;

tests/Models/StockModelTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function it_will_set_retrieve_update_too_many_failures(): void
3939

4040
$model->failed();
4141

42-
$this->assertEquals(101, $model->fail_count);
42+
$this->assertEquals(0, $model->fail_count);
4343
$this->assertFalse($model->retrieve);
4444
$this->assertFalse($model->update);
4545
}

0 commit comments

Comments
 (0)