Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeholder committed Nov 12, 2024
1 parent c627253 commit ad4a83a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/elements/CommerceProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use craft\commerce\models\inventory\UpdateInventoryLevel;
use craft\commerce\models\InventoryLevel;
use craft\commerce\Plugin as Commerce;
use craft\commerce\Plugin as CommercePlugin;
use craft\commerce\services\CatalogPricing;
use craft\db\Query;
use craft\feedme\base\Element;
use craft\feedme\events\FeedProcessEvent;
Expand Down Expand Up @@ -52,6 +54,11 @@ class CommerceProduct extends Element
*/
public static string $class = ProductElement::class;

/**
* @var bool
*/
private bool $_runCatalogPricingJob = false;

// Templates
// =========================================================================

Expand Down Expand Up @@ -126,6 +133,17 @@ public function init(): void
$this->_inventoryUpdate($event);
}
});

if(defined(CatalogPricing::class.'::EVENT_BEFORE_CREATE_CATALOG_PRICING_JOB')){
Event::on(CatalogPricing::class, CatalogPricing::EVENT_BEFORE_CREATE_CATALOG_PRICING_JOB, function( $event) {
$event->isValid = $this->_runCatalogPricingJob;
});
}

Event::on(Process::class, Process::EVENT_AFTER_PROCESS_FEED, function(FeedProcessEvent $event) {
$this->_runCatalogPricingJob = true;
CommercePlugin::getInstance()->getCatalogPricing()->createCatalogPricingJob();
});
}

/**
Expand Down

0 comments on commit ad4a83a

Please sign in to comment.