Files
2025-03-12 17:06:23 +01:00

59 lines
1.8 KiB
PHP

<?php
class stDepositoryBackendActions extends autoStDepositoryBackendActions
{
public function executeOptionsList()
{
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
$data = $this->getRequestParameter('product_options_value');
$productOptions = ProductOptionsValuePeer::retrieveByPKs(array_keys($data));
$last = end($productOptions);
stFastCacheManager::disableClearCache();
stPartialCache::disableClearCache();
stFunctionCache::disableClearCache();
foreach ($productOptions as $option)
{
if ($last->getId() != $option->getId())
{
$option->disableProductUpdate();
}
$current = $data[$option->getId()];
$option->setStock(isset($current['stock_enabled']) ? $current['stock'] : null);
$option->save();
}
stFastCacheManager::enableClearCache();
stPartialCache::enableClearCache();
stFunctionCache::enableClearCache();
ProductHasCategoryPeer::cleanCache();
stFastCacheManager::clearCache();
}
stAdminGeneratorHelper::setCurrentMenuPath('@stDepositoryPlugin?action=list');
return parent::executeOptionsList();
}
protected function filterCriteriaByProductAvailabilityId(Criteria $c, $value)
{
if (!$value)
{
$cc = $c->getNewCriterion(ProductPeer::AVAILABILITY_ID, null, Criteria::ISNULL);
$cc->addOr($c->getNewCriterion(ProductPeer::AVAILABILITY_ID, 0));
$c->add($cc);
}
else
{
$c->add(ProductPeer::AVAILABILITY_ID, $value);
}
return true;
}
}