// fix norm && added PDO::FETCH_ASSOC in method fetch() for PDO
This commit is contained in:
+94
-81
@@ -75,7 +75,7 @@ class ImageCore extends ObjectModel
|
|||||||
|
|
||||||
protected static $_cacheGetSize = array();
|
protected static $_cacheGetSize = array();
|
||||||
|
|
||||||
public function __construct($id = NULL, $id_lang = NULL)
|
public function __construct($id = null, $id_lang = null)
|
||||||
{
|
{
|
||||||
parent::__construct($id, $id_lang);
|
parent::__construct($id, $id_lang);
|
||||||
$this->image_dir = _PS_PROD_IMG_DIR_;
|
$this->image_dir = _PS_PROD_IMG_DIR_;
|
||||||
@@ -85,9 +85,9 @@ class ImageCore extends ObjectModel
|
|||||||
public function getFields()
|
public function getFields()
|
||||||
{
|
{
|
||||||
$this->validateFields();
|
$this->validateFields();
|
||||||
$fields['id_product'] = (int)($this->id_product);
|
$fields['id_product'] = (int)$this->id_product;
|
||||||
$fields['position'] = (int)($this->position);
|
$fields['position'] = (int)$this->position;
|
||||||
$fields['cover'] = (int)($this->cover);
|
$fields['cover'] = (int)$this->cover;
|
||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,17 +114,23 @@ class ImageCore extends ObjectModel
|
|||||||
|
|
||||||
// update positions
|
// update positions
|
||||||
$result = Db::getInstance()->executeS('
|
$result = Db::getInstance()->executeS('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM `'._DB_PREFIX_.'image`
|
FROM `'._DB_PREFIX_.'image`
|
||||||
WHERE `id_product` = '.(int)$this->id_product.'
|
WHERE `id_product` = '.(int)$this->id_product.'
|
||||||
ORDER BY `position`');
|
ORDER BY `position`
|
||||||
|
');
|
||||||
$i = 1;
|
$i = 1;
|
||||||
if ($result)
|
if ($result)
|
||||||
foreach ($result AS $row)
|
foreach ($result as $row)
|
||||||
{
|
{
|
||||||
$row['position'] = $i++;
|
$row['position'] = $i++;
|
||||||
Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->table, $row, 'UPDATE', '`id_image` = '.(int)($row['id_image']), 1);
|
Db::getInstance()->AutoExecute(
|
||||||
}
|
_DB_PREFIX_.$this->table,
|
||||||
|
$row,
|
||||||
|
'UPDATE',
|
||||||
|
'`id_image` = '.(int)$row['id_image'], 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -170,7 +176,7 @@ class ImageCore extends ObjectModel
|
|||||||
$result = Db::getInstance()->getRow('
|
$result = Db::getInstance()->getRow('
|
||||||
SELECT COUNT(`id_image`) AS total
|
SELECT COUNT(`id_image`) AS total
|
||||||
FROM `'._DB_PREFIX_.'image`
|
FROM `'._DB_PREFIX_.'image`
|
||||||
WHERE `id_product` = '.(int)($id_product));
|
WHERE `id_product` = '.(int)$id_product);
|
||||||
return $result['total'];
|
return $result['total'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,7 +191,7 @@ class ImageCore extends ObjectModel
|
|||||||
$result = Db::getInstance()->getRow('
|
$result = Db::getInstance()->getRow('
|
||||||
SELECT MAX(`position`) AS max
|
SELECT MAX(`position`) AS max
|
||||||
FROM `'._DB_PREFIX_.'image`
|
FROM `'._DB_PREFIX_.'image`
|
||||||
WHERE `id_product` = '.(int)($id_product));
|
WHERE `id_product` = '.(int)$id_product);
|
||||||
return $result['max'];
|
return $result['max'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,10 +208,12 @@ class ImageCore extends ObjectModel
|
|||||||
|
|
||||||
if (file_exists(_PS_TMP_IMG_DIR_.'product_'.$id_product.'.jpg'))
|
if (file_exists(_PS_TMP_IMG_DIR_.'product_'.$id_product.'.jpg'))
|
||||||
unlink(_PS_TMP_IMG_DIR_.'product_'.$id_product.'.jpg');
|
unlink(_PS_TMP_IMG_DIR_.'product_'.$id_product.'.jpg');
|
||||||
|
|
||||||
return Db::getInstance()->execute('
|
return Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'image`
|
UPDATE `'._DB_PREFIX_.'image`
|
||||||
SET `cover` = 0
|
SET `cover` = 0
|
||||||
WHERE `id_product` = '.(int)($id_product));
|
WHERE `id_product` = '.(int)$id_product
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -217,9 +225,10 @@ class ImageCore extends ObjectModel
|
|||||||
public static function getCover($id_product)
|
public static function getCover($id_product)
|
||||||
{
|
{
|
||||||
return Db::getInstance()->getRow('
|
return Db::getInstance()->getRow('
|
||||||
SELECT * FROM `'._DB_PREFIX_.'image`
|
SELECT * FROM `'._DB_PREFIX_.'image`
|
||||||
WHERE `id_product` = '.(int)($id_product).'
|
WHERE `id_product` = '.(int)$id_product.'
|
||||||
AND `cover`= 1');
|
AND `cover`= 1
|
||||||
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -228,51 +237,51 @@ class ImageCore extends ObjectModel
|
|||||||
* @param integer $id_product_old Source product ID
|
* @param integer $id_product_old Source product ID
|
||||||
* @param boolean $id_product_new Destination product ID
|
* @param boolean $id_product_new Destination product ID
|
||||||
*/
|
*/
|
||||||
public static function duplicateProductImages($id_product_old, $id_product_new, $combinationImages)
|
public static function duplicateProductImages($id_product_old, $id_product_new, $combination_images)
|
||||||
{
|
{
|
||||||
$imagesTypes = ImageType::getImagesTypes('products');
|
$images_types = ImageType::getImagesTypes('products');
|
||||||
$result = Db::getInstance()->executeS('
|
$result = Db::getInstance()->executeS('
|
||||||
SELECT `id_image`
|
SELECT `id_image`
|
||||||
FROM `'._DB_PREFIX_.'image`
|
FROM `'._DB_PREFIX_.'image`
|
||||||
WHERE `id_product` = '.(int)($id_product_old));
|
WHERE `id_product` = '.(int)$id_product_old);
|
||||||
foreach ($result as $row)
|
foreach ($result as $row)
|
||||||
{
|
{
|
||||||
$imageOld = new Image($row['id_image']);
|
$image_old = new Image($row['id_image']);
|
||||||
$imageNew = clone $imageOld;
|
$image_new = clone $image_old;
|
||||||
$imageNew->id_product = (int)($id_product_new);
|
$image_new->id_product = (int)$id_product_new;
|
||||||
// A new id is generated for the cloned image when calling add()
|
// A new id is generated for the cloned image when calling add()
|
||||||
if ($imageNew->add())
|
if ($image_new->add())
|
||||||
{
|
{
|
||||||
$new_path = $imageNew->getPathForCreation();
|
$new_path = $image_new->getPathForCreation();
|
||||||
foreach ($imagesTypes AS $imageType)
|
foreach ($images_types as $image_type)
|
||||||
{
|
{
|
||||||
if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg'))
|
if (file_exists(_PS_PROD_IMG_DIR_.$image_old->getExistingImgPath().'-'.$image_type['name'].'.jpg'))
|
||||||
{
|
{
|
||||||
if (!Configuration::get('PS_LEGACY_IMAGES'))
|
if (!Configuration::get('PS_LEGACY_IMAGES'))
|
||||||
$imageNew->createImgFolder();
|
$image_new->createImgFolder();
|
||||||
copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'-'.$imageType['name'].'.jpg',
|
copy(_PS_PROD_IMG_DIR_.$image_old->getExistingImgPath().'-'.$image_type['name'].'.jpg',
|
||||||
$new_path.'-'.$imageType['name'].'.jpg');
|
$new_path.'-'.$image_type['name'].'.jpg');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file_exists(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg'))
|
if (file_exists(_PS_PROD_IMG_DIR_.$image_old->getExistingImgPath().'.jpg'))
|
||||||
copy(_PS_PROD_IMG_DIR_.$imageOld->getExistingImgPath().'.jpg', $new_path.'.jpg');
|
copy(_PS_PROD_IMG_DIR_.$image_old->getExistingImgPath().'.jpg', $new_path.'.jpg');
|
||||||
|
|
||||||
self::replaceAttributeImageAssociationId($combinationImages, (int)($imageOld->id), (int)($imageNew->id));
|
self::replaceAttributeImageAssociationId($combination_images, (int)$image_old->id, (int)$image_new->id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return self::duplicateAttributeImageAssociations($combinationImages);
|
return self::duplicateAttributeImageAssociations($combination_images);
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected function replaceAttributeImageAssociationId(&$combinationImages, $saved_id, $id_image)
|
protected static function replaceAttributeImageAssociationId(&$combination_images, $saved_id, $id_image)
|
||||||
{
|
{
|
||||||
if (!isset($combinationImages['new']) OR !is_array($combinationImages['new']))
|
if (!isset($combination_images['new']) || !is_array($combination_images['new']))
|
||||||
return ;
|
return;
|
||||||
foreach ($combinationImages['new'] AS $id_product_attribute => $imageIds)
|
foreach ($combination_images['new'] as $id_product_attribute => $image_ids)
|
||||||
foreach ($imageIds AS $key => $imageId)
|
foreach ($image_ids as $key => $image_id)
|
||||||
if ((int)($imageId) == (int)($saved_id))
|
if ((int)$image_id == (int)$saved_id)
|
||||||
$combinationImages['new'][$id_product_attribute][$key] = (int)($id_image);
|
$combination_images['new'][$id_product_attribute][$key] = (int)$id_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -280,14 +289,14 @@ class ImageCore extends ObjectModel
|
|||||||
* @param integer $id_product_attribute_old
|
* @param integer $id_product_attribute_old
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function duplicateAttributeImageAssociations($combinationImages)
|
public static function duplicateAttributeImageAssociations($combination_images)
|
||||||
{
|
{
|
||||||
if (!isset($combinationImages['new']) OR !is_array($combinationImages['new']))
|
if (!isset($combination_images['new']) || !is_array($combination_images['new']))
|
||||||
return true;
|
return true;
|
||||||
$query = 'INSERT INTO `'._DB_PREFIX_.'product_attribute_image` (`id_product_attribute`, `id_image`) VALUES ';
|
$query = 'INSERT INTO `'._DB_PREFIX_.'product_attribute_image` (`id_product_attribute`, `id_image`) VALUES ';
|
||||||
foreach ($combinationImages['new'] AS $id_product_attribute => $imageIds)
|
foreach ($combination_images['new'] as $id_product_attribute => $image_ids)
|
||||||
foreach ($imageIds AS $imageId)
|
foreach ($image_ids as $image_id)
|
||||||
$query .= '('.(int)($id_product_attribute).', '.(int)($imageId).'), ';
|
$query .= '('.(int)$id_product_attribute.', '.(int)$image_id.'), ';
|
||||||
$query = rtrim($query, ', ');
|
$query = rtrim($query, ', ');
|
||||||
return DB::getInstance()->Execute($query);
|
return DB::getInstance()->Execute($query);
|
||||||
}
|
}
|
||||||
@@ -303,28 +312,28 @@ class ImageCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
Tools::displayAsDeprecated();
|
Tools::displayAsDeprecated();
|
||||||
|
|
||||||
$position = (int)($position);
|
$position = (int)$position;
|
||||||
$direction = (int)($direction);
|
$direction = (int)$direction;
|
||||||
|
|
||||||
// temporary position
|
// temporary position
|
||||||
$high_position = Image::getHighestPosition($this->id_product) + 1;
|
$high_position = Image::getHighestPosition($this->id_product) + 1;
|
||||||
|
|
||||||
Db::getInstance()->execute('
|
Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'image`
|
UPDATE `'._DB_PREFIX_.'image`
|
||||||
SET `position` = '.(int)($high_position).'
|
SET `position` = '.(int)$high_position.'
|
||||||
WHERE `id_product` = '.(int)($this->id_product).'
|
WHERE `id_product` = '.(int)$this->id_product.'
|
||||||
AND `position` = '.($direction ? $position - 1 : $position + 1));
|
AND `position` = '.($direction ? $position - 1 : $position + 1));
|
||||||
|
|
||||||
Db::getInstance()->execute('
|
Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'image`
|
UPDATE `'._DB_PREFIX_.'image`
|
||||||
SET `position` = `position`'.($direction ? '-1' : '+1').'
|
SET `position` = `position`'.($direction ? '-1' : '+1').'
|
||||||
WHERE `id_image` = '.(int)($this->id));
|
WHERE `id_image` = '.(int)$this->id);
|
||||||
|
|
||||||
Db::getInstance()->execute('
|
Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'image`
|
UPDATE `'._DB_PREFIX_.'image`
|
||||||
SET `position` = '.$this->position.'
|
SET `position` = '.$this->position.'
|
||||||
WHERE `id_product` = '.(int)($this->id_product).'
|
WHERE `id_product` = '.(int)$this->id_product.'
|
||||||
AND `position` = '.(int)($high_position));
|
AND `position` = '.(int)$high_position);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -346,21 +355,25 @@ class ImageCore extends ObjectModel
|
|||||||
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
SET `position`= `position` '.($way ? '- 1' : '+ 1').'
|
||||||
WHERE `position`
|
WHERE `position`
|
||||||
'.($way
|
'.($way
|
||||||
? '> '.(int)($this->position).' AND `position` <= '.(int)($position)
|
? '> '.(int)$this->position.' AND `position` <= '.(int)$position
|
||||||
: '< '.(int)($this->position).' AND `position` >= '.(int)($position)).'
|
: '< '.(int)$this->position.' AND `position` >= '.(int)$position).'
|
||||||
AND `id_product`='.(int)($this->id_product))
|
AND `id_product`='.(int)$this->id_product)
|
||||||
&& Db::getInstance()->execute('
|
&& Db::getInstance()->execute('
|
||||||
UPDATE `'._DB_PREFIX_.'image`
|
UPDATE `'._DB_PREFIX_.'image`
|
||||||
SET `position` = '.(int)($position).'
|
SET `position` = '.(int)$position.'
|
||||||
WHERE `id_image` = '.(int)($this->id_image)));
|
WHERE `id_image` = '.(int)$this->id_image));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSize($type)
|
public static function getSize($type)
|
||||||
{
|
{
|
||||||
if (!isset(self::$_cacheGetSize[$type]) OR self::$_cacheGetSize[$type] === NULL)
|
if (!isset(self::$_cacheGetSize[$type]) || self::$_cacheGetSize[$type] === null)
|
||||||
self::$_cacheGetSize[$type] = Db::getInstance()->getRow('SELECT `width`, `height` FROM '._DB_PREFIX_.'image_type WHERE `name` = \''.pSQL($type).'\'');
|
self::$_cacheGetSize[$type] = Db::getInstance()->getRow('
|
||||||
|
SELECT `width`, `height`
|
||||||
|
FROM '._DB_PREFIX_.'image_type
|
||||||
|
WHERE `name` = \''.pSQL($type).'\'
|
||||||
|
');
|
||||||
return self::$_cacheGetSize[$type];
|
return self::$_cacheGetSize[$type];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +382,7 @@ class ImageCore extends ObjectModel
|
|||||||
*/
|
*/
|
||||||
public static function clearTmpDir()
|
public static function clearTmpDir()
|
||||||
{
|
{
|
||||||
foreach (scandir(_PS_TMP_IMG_DIR_) AS $d)
|
foreach (scandir(_PS_TMP_IMG_DIR_) as $d)
|
||||||
if (preg_match('/(.*)\.jpg$/', $d))
|
if (preg_match('/(.*)\.jpg$/', $d))
|
||||||
unlink(_PS_TMP_IMG_DIR_.$d);
|
unlink(_PS_TMP_IMG_DIR_.$d);
|
||||||
}
|
}
|
||||||
@@ -381,9 +394,9 @@ class ImageCore extends ObjectModel
|
|||||||
return Db::getInstance()->execute('
|
return Db::getInstance()->execute('
|
||||||
DELETE
|
DELETE
|
||||||
FROM `'._DB_PREFIX_.'product_attribute_image`
|
FROM `'._DB_PREFIX_.'product_attribute_image`
|
||||||
WHERE `id_image` = '.(int)($this->id)
|
WHERE `id_image` = '.(int)$this->id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the product image from disk and remove the containing folder if empty
|
* Delete the product image from disk and remove the containing folder if empty
|
||||||
@@ -403,9 +416,9 @@ class ImageCore extends ObjectModel
|
|||||||
$files_to_delete = array();
|
$files_to_delete = array();
|
||||||
|
|
||||||
// Delete auto-generated images
|
// Delete auto-generated images
|
||||||
$imageTypes = ImageType::getImagesTypes();
|
$image_types = ImageType::getImagesTypes();
|
||||||
foreach ($imageTypes AS $imageType)
|
foreach ($image_types as $image_type)
|
||||||
$files_to_delete[] = $this->image_dir.$this->getExistingImgPath().'-'.$imageType['name'].'.'.$this->image_format;
|
$files_to_delete[] = $this->image_dir.$this->getExistingImgPath().'-'.$image_type['name'].'.'.$this->image_format;
|
||||||
|
|
||||||
// Delete watermark image
|
// Delete watermark image
|
||||||
$files_to_delete[] = $this->image_dir.$this->getExistingImgPath().'-watermark.'.$this->image_format;
|
$files_to_delete[] = $this->image_dir.$this->getExistingImgPath().'-watermark.'.$this->image_format;
|
||||||
@@ -443,7 +456,7 @@ class ImageCore extends ObjectModel
|
|||||||
* @param string $format image format
|
* @param string $format image format
|
||||||
* @return bool success
|
* @return bool success
|
||||||
*/
|
*/
|
||||||
public static function deleteAllImages($path, $format='jpg')
|
public static function deleteAllImages($path, $format = 'jpg')
|
||||||
{
|
{
|
||||||
if (!$path || !$format || !is_dir($path))
|
if (!$path || !$format || !is_dir($path))
|
||||||
return false;
|
return false;
|
||||||
@@ -460,7 +473,7 @@ class ImageCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$remove_folder = true;
|
$remove_folder = true;
|
||||||
foreach (scandir($path) as $file)
|
foreach (scandir($path) as $file)
|
||||||
if (($file != '.' && $file != '..'&& $file != 'index.php'))
|
if (($file != '.' && $file != '..' && $file != 'index.php'))
|
||||||
{
|
{
|
||||||
$remove_folder = false;
|
$remove_folder = false;
|
||||||
break;
|
break;
|
||||||
@@ -590,7 +603,7 @@ class ImageCore extends ObjectModel
|
|||||||
if (!$image || $image->id !== (int)$matches[2])
|
if (!$image || $image->id !== (int)$matches[2])
|
||||||
$image = new Image((int)$matches[2]);
|
$image = new Image((int)$matches[2]);
|
||||||
// image exists in DB and with the correct product?
|
// image exists in DB and with the correct product?
|
||||||
if (Validate::isLoadedObject($image) && $image->id_product == (int)rtrim($matches[1], "-"))
|
if (Validate::isLoadedObject($image) && $image->id_product == (int)rtrim($matches[1], '-'))
|
||||||
{
|
{
|
||||||
// create the new folder if it does not exist
|
// create the new folder if it does not exist
|
||||||
if (!$image->createImgFolder())
|
if (!$image->createImgFolder())
|
||||||
@@ -600,16 +613,16 @@ class ImageCore extends ObjectModel
|
|||||||
// most likely the preexisting image is a demo image not linked to a product and it's ok to replace it
|
// most likely the preexisting image is a demo image not linked to a product and it's ok to replace it
|
||||||
$new_path = _PS_PROD_IMG_DIR_.$image->getImgPath().(isset($matches[3]) ? $matches[3] : '').'.jpg';
|
$new_path = _PS_PROD_IMG_DIR_.$image->getImgPath().(isset($matches[3]) ? $matches[3] : '').'.jpg';
|
||||||
if (file_exists($new_path))
|
if (file_exists($new_path))
|
||||||
|
{
|
||||||
|
if (!file_exists(_PS_PROD_IMG_DIR_.$tmp_folder))
|
||||||
{
|
{
|
||||||
if (!file_exists(_PS_PROD_IMG_DIR_.$tmp_folder))
|
@mkdir(_PS_PROD_IMG_DIR_.$tmp_folder, self::$access_rights);
|
||||||
{
|
@chmod(_PS_PROD_IMG_DIR_.$tmp_folder, self::$access_rights);
|
||||||
@mkdir(_PS_PROD_IMG_DIR_.$tmp_folder, self::$access_rights);
|
|
||||||
@chmod(_PS_PROD_IMG_DIR_.$tmp_folder, self::$access_rights);
|
|
||||||
}
|
|
||||||
$tmp_path = _PS_PROD_IMG_DIR_.$tmp_folder.basename($file);
|
|
||||||
if (!@rename($new_path, $tmp_path) || !file_exists($tmp_path))
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
$tmp_path = _PS_PROD_IMG_DIR_.$tmp_folder.basename($file);
|
||||||
|
if (!@rename($new_path, $tmp_path) || !file_exists($tmp_path))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// move the image
|
// move the image
|
||||||
if (!@rename(_PS_PROD_IMG_DIR_.$file, $new_path) || !file_exists($new_path))
|
if (!@rename(_PS_PROD_IMG_DIR_.$file, $new_path) || !file_exists($new_path))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+9
-9
@@ -677,7 +677,6 @@ class ProductCore extends ObjectModel
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
Hook::exec('deleteProduct', array('product' => $this));
|
Hook::exec('deleteProduct', array('product' => $this));
|
||||||
|
|
||||||
if (!parent::delete() ||
|
if (!parent::delete() ||
|
||||||
!$this->deleteCategories(true) ||
|
!$this->deleteCategories(true) ||
|
||||||
!$this->deleteImages() ||
|
!$this->deleteImages() ||
|
||||||
@@ -888,17 +887,18 @@ class ProductCore extends ObjectModel
|
|||||||
public function deleteImages()
|
public function deleteImages()
|
||||||
{
|
{
|
||||||
$result = Db::getInstance()->executeS('
|
$result = Db::getInstance()->executeS('
|
||||||
SELECT `id_image`
|
SELECT `id_image`
|
||||||
FROM `'._DB_PREFIX_.'image`
|
FROM `'._DB_PREFIX_.'image`
|
||||||
WHERE `id_product` = '.(int)$this->id);
|
WHERE `id_product` = '.(int)$this->id
|
||||||
|
);
|
||||||
|
|
||||||
$status = true;
|
$status = true;
|
||||||
if ($result)
|
if ($result)
|
||||||
foreach ($result as $row)
|
foreach ($result as $row)
|
||||||
{
|
{
|
||||||
$image = new Image($row['id_image']);
|
$image = new Image($row['id_image']);
|
||||||
$status &= $image->delete();
|
$status &= $image->delete();
|
||||||
}
|
}
|
||||||
return $status;
|
return $status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class DbPDOCore extends Db
|
|||||||
{
|
{
|
||||||
if (!$result)
|
if (!$result)
|
||||||
$result = $this->result;
|
$result = $this->result;
|
||||||
return $result->fetch();
|
return $result->fetch(PDO::FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<module>
|
<module>
|
||||||
<name>statsstock</name>
|
<name>statsstock</name>
|
||||||
<displayName><![CDATA[Stock stats]]></displayName>
|
<displayName><![CDATA[Available quantities stats]]></displayName>
|
||||||
<version><![CDATA[1]]></version>
|
<version><![CDATA[1]]></version>
|
||||||
<description><![CDATA[]]></description>
|
<description><![CDATA[]]></description>
|
||||||
<author><![CDATA[PrestaShop]]></author>
|
<author><![CDATA[PrestaShop]]></author>
|
||||||
|
|||||||
Reference in New Issue
Block a user