Skip to content

Commit

Permalink
updating the logs to be able to diagnose the queueing of product in c…
Browse files Browse the repository at this point in the history
…raft commerce
  • Loading branch information
markmiddleton committed Nov 13, 2023
1 parent 9098c01 commit aa0a6fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
13 changes: 5 additions & 8 deletions src/jobs/AlgoliaBulkLoadTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function execute($queue)
$queue->push(new AlgoliaChunkLoadTask([
'description' => Craft::t('algolia-sync', 'Queueing a chunk of records to process start ('.$x.') limit ('.$this->standardLimit.')'),
'loadRecordType' => $this->loadRecordType,
'limit' => 100,
'limit' => $this->standardLimit,
'offset' => $x,
'elementType' => $elementType
]));
Expand All @@ -141,20 +141,19 @@ public function execute($queue)

if ($commercePlugin) {

// this is the total number of variants in the system
$variantCount = \craft\commerce\elements\Variant::find()->typeId($sectionId)->count();

$queue = Craft::$app->getQueue();

for ($x=0; $x<$variantCount; $x=$x+$this->standardLimit) {

$queue->push(new AlgoliaChunkLoadTask([
'description' => Craft::t('algolia-sync', 'Queueing a chunk of records to process start ('.$x.') limit ('.$this->standardLimit.')'),
'description' => Craft::t('algolia-sync', 'Queueing a chunk of '.$this->loadRecordType.' records to process start ('.$x.') limit ('.$this->standardLimit.')'),
'loadRecordType' => $this->loadRecordType,
'limit' => 100,
'limit' => $this->standardLimit,
'offset' => $x,
'elementType' => $elementType
]));

]));
}
}
break;
Expand Down Expand Up @@ -185,8 +184,6 @@ public function execute($queue)
$queue = Craft::$app->getQueue();

for ($x=0; $x<$userCount; $x=$x+$this->standardLimit) {
print_r('count: '.$x);

$progress = $x / $this->standardLimit;
$this->setProgress($queue, $progress);

Expand Down
6 changes: 3 additions & 3 deletions src/jobs/AlgoliaChunkLoadTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function execute($queue)

CASE 'variant':

AlgoliaSync::$plugin->algoliaSyncService->logger("loading a chunk of product variants into the Algolia sync queue", basename(__FILE__) , __LINE__);
AlgoliaSync::$plugin->algoliaSyncService->logger("loading a chunk of product variants (with type ID = ".$sectionId.") into the Algolia sync queue. OffsetCount=".$offsetCount.", limitCount=".$limitCount, basename(__FILE__) , __LINE__);

$commercePlugin = Craft::$app->plugins->getPlugin('commerce');

Expand All @@ -106,14 +106,14 @@ public function execute($queue)
$variants = \craft\commerce\elements\Variant::find()->typeId($sectionId)->offset($offsetCount)->limit($limitCount)->status('enabled')->all();

if ($recordCount > 0) {
AlgoliaSync::$plugin->algoliaSyncService->logger("Now loading ".$recordCount." products to be synced", basename(__FILE__) , __LINE__);
AlgoliaSync::$plugin->algoliaSyncService->logger("We found ".$recordCount." products that need to be synced in this batch to be synced", basename(__FILE__) , __LINE__);

$currentLoopCount = 0;
foreach ($variants as $variant) {
$progress = $currentLoopCount / $recordCount;
$this->setProgress($queue, $progress);

AlgoliaSync::$plugin->algoliaSyncService->logger(print_r($variant, true), basename(__FILE__) , __LINE__);
// AlgoliaSync::$plugin->algoliaSyncService->logger(print_r($variant, true), basename(__FILE__) , __LINE__);

AlgoliaSync::$plugin->algoliaSyncService->prepareAlgoliaSyncElement($variant);
$currentLoopCount++;
Expand Down

0 comments on commit aa0a6fa

Please sign in to comment.