// #PSTEST-1229 - remove virtual combinations

This commit is contained in:
tDidierjean
2012-04-24 13:23:02 +00:00
parent 744df9b3b2
commit dbae669d5f
8 changed files with 73 additions and 472 deletions
-80
View File
@@ -30,9 +30,6 @@ class ProductDownloadCore extends ObjectModel
/** @var integer Product id which download belongs */
public $id_product;
/** @var integer Attribute Product id which download belongs */
public $id_product_attribute;
/** @var string DisplayFilename the name which appear */
public $display_filename;
@@ -67,7 +64,6 @@ class ProductDownloadCore extends ObjectModel
'primary' => 'id_product_download',
'fields' => array(
'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'display_filename' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255),
'filename' => array('type' => self::TYPE_STRING, 'validate' => 'isSha1', 'size' => 255),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
@@ -192,64 +188,6 @@ class ProductDownloadCore extends ObjectModel
return self::$_productIds[$id_product];
}
/**
* Return the id_product_download from an id_product
* @since 1.5.0.1
* @param int $id_product Product the id
* @return integer Product the id for this virtual product
*/
public static function getIdFromIdAttribute($id_product, $id_product_attribute)
{
if (!ProductDownload::isFeatureActive())
return false;
if (array_key_exists($id_product_attribute, self::$_productIds))
return self::$_productIds[$id_product];
self::$_productIds[$id_product_attribute] = (int)Db::getInstance()->getValue('
SELECT `id_product_download`
FROM `'._DB_PREFIX_.'product_download`
WHERE `id_product` = '.(int)$id_product.'
AND `id_product_attribute` = '.(int)$id_product_attribute.'
AND `active` = 1'
);
return self::$_productIds[$id_product_attribute];
}
/**
* Return the display filename from a physical filename
*
* @since 1.5.0.1
*
* @param string $filename Filename physically
* @return integer Product the id for this virtual product
*
*/
public static function getAttributeFromIdProduct($id_product)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT `id_product_download`
FROM `'._DB_PREFIX_.'product_download`
WHERE `id_product` = '.(int)$id_product.' AND `active` = 1');
}
/**
* Return the result from an id_product_attribute
*
* @param int $id_product Product the id
* @param int $id_product_attribute Attribute the id
* @return array result for this virtual product
*/
public static function getAttributeFromIdAttribute($id_product, $id_product_attribute)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT *
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
*
@@ -283,24 +221,6 @@ class ProductDownloadCore extends ObjectModel
');
}
/**
* 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
*
+1 -4
View File
@@ -568,10 +568,7 @@ class OrderCore extends ObjectModel
// Add information for virtual product
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']);
$row['filename'] = ProductDownload::getFilenameFromIdProduct((int)$row['product_id']);
// Get the display filename
$row['display_filename'] = ProductDownload::getFilenameFromFilename($row['filename']);
}
+1 -1
View File
@@ -321,7 +321,7 @@ class OrderHistoryCore extends ObjectModel
$assign = array();
foreach ($virtual_products as $key => $virtual_product)
{
$id_product_download = ProductDownload::getIdFromIdAttribute($virtual_product['product_id'], $virtual_product['product_attribute_id']);
$id_product_download = ProductDownload::getIdFromIdProduct($virtual_product['product_id']);
$product_download = new ProductDownload($id_product_download);
// If this virtual item has an associated file, we'll provide the link to download the file in the email
if ($product_download->display_filename != '')
+1 -4
View File
@@ -150,10 +150,7 @@ class OrderInvoiceCore extends ObjectModel
// Add information for virtual product
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']);
$row['filename'] = ProductDownload::getFilenameFromIdProduct((int)$row['product_id']);
// Get the display filename
$row['display_filename'] = ProductDownload::getFilenameFromFilename($row['filename']);
}