[*] FO : Update filename if product has combinations (and files associated to them)
This commit is contained in:
+13
-3
@@ -495,12 +495,22 @@ class OrderCore extends ObjectModel
|
||||
$this->setProductPrices($row);
|
||||
|
||||
/* Add information for virtual product */
|
||||
if ($row['download_hash'] AND !empty($row['download_hash']))
|
||||
$row['filename'] = ProductDownload::getFilenameFromIdProduct($row['product_id']);
|
||||
|
||||
if ($row['download_hash'] && !empty($row['download_hash']))
|
||||
{
|
||||
if ($row['product_attribute_id'] && !empty($row['product_attribute_id']))
|
||||
{
|
||||
$row['filename'] = ProductDownload::getFilenameFromIdAttribute((int)$row['product_id'], (int)$row['product_attribute_id']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$row['filename'] = ProductDownload::getFilenameFromIdProduct((int)$row['product_id']);
|
||||
}
|
||||
}
|
||||
/* Stock product */
|
||||
$resultArray[(int)$row['id_order_detail']] = $row;
|
||||
}
|
||||
p($resultArray);
|
||||
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +269,23 @@ class ProductDownloadCore extends ObjectModel
|
||||
WHERE `id_product` = '.(int)$id_product.'
|
||||
AND `active` = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the filename from an id_product_attribute
|
||||
*
|
||||
* @param int $id_product Product the id
|
||||
* @param int $id_product_attribute Attribute the id
|
||||
* @return string Filename the filename for this virtual product
|
||||
*/
|
||||
public static function getFilenameFromIdAttribute($id_product, $id_product_attribute)
|
||||
{
|
||||
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
|
||||
SELECT `filename`
|
||||
FROM `'._DB_PREFIX_.'product_download`
|
||||
WHERE `id_product` = '.(int)$id_product.'
|
||||
AND `id_product_attribute` = '.(int)$id_product_attribute.'
|
||||
AND `active` = 1');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the display filename from a physical filename
|
||||
|
||||
Reference in New Issue
Block a user