[-] MO dateofdelivery : FixBug #PNM-1478 Now take care of product available date
This commit is contained in:
1 parent
e80364984a
commit
23e0467993
2 files changed
+44
-4
No files matched your search
@@ -668,6 +668,45 @@ class ProductCore extends ObjectModel
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For a given id_product and id_product_attribute, return available date
|
||||||
|
*
|
||||||
|
* @param int $id_product
|
||||||
|
* @param int $id_product_attribute Optional
|
||||||
|
* @return string/null
|
||||||
|
*/
|
||||||
|
public static function getAvailableDate($id_product, $id_product_attribute = null)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT';
|
||||||
|
|
||||||
|
if ($id_product_attribute === null)
|
||||||
|
$sql .= ' p.`available_date`';
|
||||||
|
else
|
||||||
|
$sql .= ' IF(pa.`available_date` = "0000-00-00", p.`available_date`, pa.`available_date`) AS available_date';
|
||||||
|
|
||||||
|
$sql .= ' FROM `'._DB_PREFIX_.'product` p';
|
||||||
|
|
||||||
|
if ($id_product_attribute !== null)
|
||||||
|
$sql .= ' LEFT JOIN `'._DB_PREFIX_.'product_attribute` pa ON (pa.`id_product` = p.`id_product`)';
|
||||||
|
|
||||||
|
$sql .= Shop::addSqlAssociation('product', 'p');
|
||||||
|
|
||||||
|
if ($id_product_attribute !== null)
|
||||||
|
$sql .= Shop::addSqlAssociation('product_attribute', 'pa');
|
||||||
|
|
||||||
|
$sql .= ' WHERE p.`id_product` = '.(int)$id_product;
|
||||||
|
|
||||||
|
if ($id_product_attribute !== null)
|
||||||
|
$sql .= ' AND pa.`id_product` = '.(int)$id_product.' AND pa.`id_product_attribute` = '.(int)$id_product_attribute;
|
||||||
|
|
||||||
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
|
||||||
|
|
||||||
|
if ($result == '0000-00-00')
|
||||||
|
$result = null;
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
public static function updateIsVirtual($id_product)
|
public static function updateIsVirtual($id_product)
|
||||||
{
|
{
|
||||||
Db::getInstance()->update('product', array(
|
Db::getInstance()->update('product', array(
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ class DateOfDelivery extends Module
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$date_range = $this->_getDatesOfDelivery($id_carrier, $oos);
|
$available_date = Product::getAvailableDate($product['id_product'], $product['id_product_attribute']);
|
||||||
|
$date_range = $this->_getDatesOfDelivery($id_carrier, $oos, $available_date);
|
||||||
if (is_null($date_from) || $date_from < $date_range[0])
|
if (is_null($date_from) || $date_from < $date_range[0])
|
||||||
{
|
{
|
||||||
$date_from = $date_range[0][1];
|
$date_from = $date_range[0][1];
|
||||||
@@ -493,9 +494,9 @@ class DateOfDelivery extends Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $id_carrier
|
* @param int $id_carrier
|
||||||
* @param bool $product_oos
|
* @param bool $product_oos
|
||||||
* @param null $date
|
* @param string $date
|
||||||
*
|
*
|
||||||
* @return array|bool returns the min & max delivery date
|
* @return array|bool returns the min & max delivery date
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in new issue
Block a user