| 1 |
<?php |
| 2 |
|
| 3 |
namespace SyncBasalam\Queue\Tasks; |
| 4 |
|
| 5 |
use SyncBasalam\Admin\Product\ProductOperations; |
| 6 |
use SyncBasalam\AsyncBackgroundProcess; |
| 7 |
|
| 8 |
defined('ABSPATH') || exit; |
| 9 |
|
| 10 |
class CreateProduct extends AsyncBackgroundProcess |
| 11 |
{ |
| 12 |
protected $action = 'CreateSingleProduct'; |
| 13 |
protected $batch_size = 1; |
| 14 |
private $operator; |
| 15 |
|
| 16 |
public function __construct($operator = null) |
| 17 |
{ |
| 18 |
parent::__construct(); |
| 19 |
$this->operator = $operator ?: syncBasalamContainer()->get(ProductOperations::class); |
| 20 |
} |
| 21 |
|
| 22 |
protected function task($item) |
| 23 |
{ |
| 24 |
$this->operator->createNewProduct($item['id'], null); |
| 25 |
|
| 26 |
return false; |
| 27 |
} |
| 28 |
|
| 29 |
protected function complete() |
| 30 |
{ |
| 31 |
parent::complete(); |
| 32 |
} |
| 33 |
|
| 34 |
public function isActive() |
| 35 |
{ |
| 36 |
return get_site_transient($this->identifier . '_process_lock') !== false; |
| 37 |
} |
| 38 |
} |
| 39 |
|