50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
class stProductOptionsStockUpdateComputationProgressBarTask extends stProgressBarTask
|
|
{
|
|
const LIMIT = 40;
|
|
|
|
public function execute($offset)
|
|
{
|
|
$c = $this->getCriteria();
|
|
$c->setLimit(self::LIMIT);
|
|
$c->setOffset($offset);
|
|
|
|
$this->setMessage($this->getI18N()->__('Aktualizacja stanów magazynowych w toku...', null, 'stProductOptionsBackend'));
|
|
|
|
foreach (ProductPeer::doSelectIds($c) as $id)
|
|
{
|
|
ProductOptionsValuePeer::updateStock($id);
|
|
$offset++;
|
|
usleep(20000);
|
|
}
|
|
|
|
return $offset;
|
|
}
|
|
|
|
public function count()
|
|
{
|
|
return ProductPeer::doCount($this->getCriteria());
|
|
}
|
|
|
|
public function finished()
|
|
{
|
|
sfLoader::loadHelpers(['Helper', 'stAdminGenerator']);
|
|
|
|
$message = $this->getI18N()->__('Stany magazynowe zaktualizowane pomyślnie.', null, 'stProductOptionsBackend') . '<br>' . st_get_admin_button('default', $this->getI18N()->__('Powrót'), '@stProduct?action=config');
|
|
$this->setMessage($message);
|
|
|
|
stPartialCache::clear('stProduct', '_productGroup', array('app' => 'frontend'));
|
|
stPartialCache::clear('stProduct', '_new', array('app' => 'frontend'));
|
|
stFastCacheManager::clearCache();
|
|
}
|
|
|
|
protected function getCriteria(): Criteria
|
|
{
|
|
$c = new Criteria();
|
|
$c->add(ProductPeer::OPT_HAS_OPTIONS, 1, Criteria::GREATER_THAN);
|
|
$c->add(ProductPeer::STOCK_MANAGMENT, ProductPeer::STOCK_PRODUCT_OPTIONS);
|
|
|
|
return $c;
|
|
}
|
|
} |