[*] FO : Update filename if product has combinations (and files associated to them)

This commit is contained in:
lBrieu
2011-10-03 13:05:08 +00:00
parent 8915f989ed
commit 3e2d0086fa
2 changed files with 30 additions and 3 deletions
+13 -3
View File
@@ -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;
}
+17
View File
@@ -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