-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
124a498
commit c60ea03
Showing
75 changed files
with
1,545 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Upgrading | ||
|
||
Documentation about upgrading to the next major version. | ||
|
||
## From 1.x to 2.x | ||
|
||
Since version 2.x, support for product models has been added. By doing so, most classes have been moved to a new namespace. The configuration is also mostly moved to the retriever class itself. | ||
|
||
### Namespaces | ||
|
||
The retriever class for products has also been changed. Please, update all references to the new namespace. | ||
|
||
```php | ||
use JustBetter\AkeneoProducts\Retrievers\BaseRetriever; | ||
|
||
// Is now | ||
|
||
use JustBetter\AkeneoProducts\Retrievers\Product\BaseProductRetriever; | ||
``` | ||
|
||
All classes related to products have also been moved within the `Product` namespace. This applies to `Actions`, `Jobs`, `Commands`, etc. Make sure to update all references as well. | ||
|
||
Example: | ||
|
||
```php | ||
use JustBetter\AkeneoProducts\Jobs\RetrieveProductJob; | ||
|
||
// Is now | ||
|
||
use JustBetter\AkeneoProducts\Jobs\Product\RetrieveProductJob; | ||
``` | ||
|
||
### Configuration | ||
|
||
In order to have a more dynamic configuration, the options have been moved to the retriever class itself. If you wish to configure the batch sizes or the amount of tries, add these properties to your retriever class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
database/migrations/2023_08_22_083000_create_akeneo_product_models_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
public function up(): void | ||
{ | ||
Schema::create('akeneo_product_models', function (Blueprint $table): void { | ||
$table->id(); | ||
$table->string('code'); | ||
$table->boolean('synchronize')->default(true); | ||
$table->boolean('retrieve')->default(false); | ||
$table->boolean('update')->default(false); | ||
$table->integer('fail_count')->default(0); | ||
$table->json('data'); | ||
$table->string('checksum')->nullable(); | ||
$table->timestamp('retrieved_at')->nullable(); | ||
$table->timestamp('modified_at')->nullable(); | ||
$table->timestamp('failed_at')->nullable(); | ||
$table->timestamps(); | ||
$table->softDeletes(); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::dropIfExists('akeneo_product_models'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
src/Actions/RetrieveProduct.php → src/Actions/Product/RetrieveProduct.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/Actions/SaveProduct.php → src/Actions/Product/SaveProduct.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/Actions/UpdateProduct.php → src/Actions/Product/UpdateProduct.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
namespace JustBetter\AkeneoProducts\Actions\ProductModel; | ||
|
||
use JustBetter\AkeneoProducts\Contracts\ProductModel\ProcessesProductModels; | ||
use JustBetter\AkeneoProducts\Jobs\ProductModel\RetrieveProductModelJob; | ||
use JustBetter\AkeneoProducts\Jobs\ProductModel\UpdateProductModelJob; | ||
use JustBetter\AkeneoProducts\Models\ProductModel; | ||
use JustBetter\AkeneoProducts\Retrievers\ProductModel\BaseProductModelRetriever; | ||
|
||
class ProcessProductModels implements ProcessesProductModels | ||
{ | ||
public function process(): void | ||
{ | ||
// If the product model has to be retrieved again, reset the update state. | ||
ProductModel::query() | ||
->where('retrieve', '=', true) | ||
->where('update', '=', true) | ||
->update(['update' => false]); | ||
|
||
$retrieveBatchSize = BaseProductModelRetriever::current()->retrieveBatchSize(); | ||
|
||
// Dispatch jobs for all product models that should be retrieved. | ||
ProductModel::query() | ||
->scopes('shouldRetrieve') | ||
->limit($retrieveBatchSize) | ||
->get() | ||
->pluck('code') | ||
->each(fn (string $code) => RetrieveProductModelJob::dispatch($code)); | ||
|
||
$updateBatchSize = BaseProductModelRetriever::current()->updateBatchSize(); | ||
|
||
// Dispatch jobs for all product models that are should be updated. | ||
ProductModel::query() | ||
->scopes('shouldUpdate') | ||
->limit($updateBatchSize) | ||
->get() | ||
->each(fn (ProductModel $productModel) => UpdateProductModelJob::dispatch($productModel)); | ||
} | ||
|
||
public static function bind(): void | ||
{ | ||
app()->singleton(ProcessesProductModels::class, static::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace JustBetter\AkeneoProducts\Actions\ProductModel; | ||
|
||
use JustBetter\AkeneoProducts\Contracts\ProductModel\RetrievesProductModel; | ||
use JustBetter\AkeneoProducts\Jobs\ProductModel\SaveProductModelJob; | ||
use JustBetter\AkeneoProducts\Retrievers\ProductModel\BaseProductModelRetriever; | ||
|
||
class RetrieveProductModel implements RetrievesProductModel | ||
{ | ||
public function retrieve(string $code): void | ||
{ | ||
$productModel = BaseProductModelRetriever::current()->retrieve($code); | ||
|
||
if ($productModel !== null) { | ||
SaveProductModelJob::dispatch($productModel); | ||
} | ||
} | ||
|
||
public static function bind(): void | ||
{ | ||
app()->singleton(RetrievesProductModel::class, static::class); | ||
} | ||
} |
Oops, something went wrong.