Skip to content

Commit

Permalink
Исправлено удаление опций при изменении и генерации картинок товара
Browse files Browse the repository at this point in the history
  • Loading branch information
argnist committed Jul 6, 2015
1 parent 21786fc commit a76579b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
15 changes: 12 additions & 3 deletions core/components/minishop2/model/minishop2/msproductdata.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class msProductData extends xPDOSimpleObject {
*
*/
public function save($cacheFlag= null) {
$save = parent::save();
$save = $this->simpleSave($cacheFlag);

$arrays = array();
foreach ($this->_fieldMeta as $name => $field) {
Expand All @@ -24,7 +24,7 @@ public function save($cacheFlag= null) {
}
}

$id = $this->get('id');
$id = $this->getPrimaryKey();
$table = $this->xpdo->getTableName('msProductOption');
$sql = 'DELETE FROM '.$table.' WHERE `product_id` = '.$id;
$stmt = $this->xpdo->prepare($sql);
Expand Down Expand Up @@ -61,6 +61,15 @@ public function save($cacheFlag= null) {
return $save;
}

/**
* Save data without custom logic
* @param null $cacheFlag
* @return bool
*/
public function simpleSave($cacheFlag = null) {
return parent::save($cacheFlag);
}

public static function loadOptions(xPDO & $xpdo, $product) {
$c = $xpdo->newQuery('msProductOption');
$c->rightJoin('msOption', 'msOption', 'msProductOption.key=msOption.key');
Expand Down Expand Up @@ -181,7 +190,7 @@ public function updateProductImage() {
}

$this->fromArray($arr);
if ($this->save()) {
if ($this->simpleSave()) {
/* @var msProduct $product */
if ($product = $this->getOne('Product')) {
$product->clearCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ public function process() {
$file->generateThumbnails();

$thumb = $file->getFirstThumbnail();
/** @var msProductData $product */
$product = $this->modx->getObject('msProductData', array('id' => $file->product_id));
$product->thumb = $thumb['url'];
if ($product->save()) {
$product->set('thumb', $thumb['url']);
if ($product->simpleSave()) {
return $this->success();
}
}
Expand Down

0 comments on commit a76579b

Please sign in to comment.