Modx revo модуль msync не обновляет остатки в базе когда они равны 0 в файле от 1C?
когда в файле импорта у товара Количество = 0, импорт вроде обновляет товара, но сами остатки остаются не изменяемыми. т.е. было 5 кол-во, должно быть 0, но все равно в базе 5... если было 0 а в файле кол-во положительное, то все нормально обновляется...
может где то в настройках что-то?
core/components/msync/model/msync/msynccataloghandler.class.php/**
* Обновление остатков товара
* @param $xml
* @param modResource $product
* @param $productFeatureExist
*/
protected function updateQuantity($xml, $product, $productFeatureExist)
{
if (!isset($this->properties['Количество'])) {
$this->log("Не настроено поле Количество для выгрузки остатков.", 1);
return;
}
$quantity = intval($xml->Количество);
$feature = $this->getFeature($xml);
if ($feature) {
if ($productFeatureExist) {
$target = $this->properties['Количество']['target'];
$type = $this->properties['Количество']['type'];
$oldQuantity = $type == 1 ? $product->get($target) : $product->getTVValue($target);
$oldQuantity = empty($oldQuantity) ? array() : (array)explode('||', $oldQuantity);
$newQuantity = array_unique(array_merge($oldQuantity, array($feature . '==' . $quantity)));
$quantity = $this->calcComplexQuantity($newQuantity);
$this->saveProductProperty($product, 'Количество', implode('||', $newQuantity));
} else {
$this->saveProductProperty($product, 'Количество', $feature . '==' . $quantity);
}
} else {
$this->saveProductProperty($product, 'Количество', $quantity);
}
$this->publishByQuantity($product, $quantity);
}
/**
* @param modResource $product
* @param string $propertyName
* @param mixed $value
* @param bool $productFeatureExist
*/
protected function saveProductProperty($product, $propertyName, $value, $productFeatureExist = false)
{
$target = $this->properties[$propertyName]['target'];
$type = $this->properties[$propertyName]['type'];
$logMsg = "Свойство {$propertyName} ({$target}) товара {$product->get('pagetitle')} ({$product->get('id')}) обновлено значением {$value}.";
if ($type == 1 && !$productFeatureExist) {
$this->updateMsProduct($product->get('parent'), $product->get('id'), array($target => $value));
$this->log($logMsg, 1);
}
if ($type == 2) {
$product->setTVValue($target, $value);
$this->log("{$logMsg} Значение записано в TV {$target}.", 1);
}
}
/**
* Update miniShop2 product
*
* @param int $categoryId
* @param int $productId
* @param array $productAddData
* @return bool|mixed
*/
protected function updateMsProduct($categoryId, $productId, $productAddData)
{
$this->clearModxErrors();
$processorProps = array_merge(array(
'id' => $productId,
'context_key' => $this->config['catalog_context'],
'source' => $this->config['product_source']
), $productAddData);
if (!empty($categoryId)) $processorProps['parent'] = $categoryId;
$response = $this->modx->runProcessor('mgr/extend/updatemsproduct', $processorProps,
array('processors_path' => $this->config['processorsPath']));
if (!$response->isError()) {
$_SESSION['importResources']['product']['updated'][] = $productId;
return true;
} else {
$this->log('Ошибка обновления товара (' . $productAddData['pagetitle'] . ' ' . $productId . '), импорт остановлен' .
"\r\n" . print_r($response->getResponse(), 1), 1, 1);
return false;
}
}