// Many improvements for Feature Detachable

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8648 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
aFolletete
2011-09-19 15:55:52 +00:00
parent 7c45913536
commit c3cc90a191
11 changed files with 180 additions and 169 deletions
+11 -11
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -30,14 +30,14 @@ class AliasCore extends ObjectModel
public $alias;
public $search;
public $active = true;
protected $fieldsRequired = array('alias', 'search');
protected $fieldsSize = array('alias' => 255, 'search' => 255);
protected $fieldsValidate = array('search' => 'isValidSearch', 'alias' => 'isValidSearch', 'active' => 'isBool');
protected $table = 'alias';
protected $identifier = 'id_alias';
protected static $feature_active = null;
function __construct($id = NULL, $alias = NULL, $search = NULL, $id_lang = NULL)
@@ -51,13 +51,13 @@ class AliasCore extends ObjectModel
$this->alias = trim($alias);
$this->search = trim($search);
}
else
else
{
$row = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
SELECT a.id_alias, a.search, a.alias
FROM `'._DB_PREFIX_.'alias` a
WHERE `alias` LIKE \''.pSQL($alias).'\' AND `active` = 1');
if ($row)
{
$this->id = (int)($row['id_alias']);
@@ -77,7 +77,7 @@ class AliasCore extends ObjectModel
{
if (!self::isFeatureActive())
return '';
$aliases = Db::getInstance()->ExecuteS('
SELECT a.alias
FROM `'._DB_PREFIX_.'alias` a
@@ -86,17 +86,17 @@ class AliasCore extends ObjectModel
$aliases = array_map('implode', $aliases);
return implode(', ', $aliases);
}
public function getFields()
{
$this->validateFields();
$fields['alias'] = pSQL($this->alias);
$fields['search'] = pSQL($this->search);
$fields['active'] = (int)($this->active);
return $fields;
}
/**
* This method is allow to know if a feature is used or active
* @since 1.5.0.1
@@ -106,10 +106,10 @@ class AliasCore extends ObjectModel
{
if (self::$feature_active === null)
self::$feature_active = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
SELECT `id_alias`
FROM `'._DB_PREFIX_.'alias`
');
return self::$feature_active;
}
}
}
+11 -11
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -36,7 +36,7 @@ class CombinationCore extends ObjectModel
public $location;
public $ean13;
public $upc;
public $wholesale_price;
@@ -83,7 +83,7 @@ class CombinationCore extends ObjectModel
protected $table = 'product_attribute';
protected $identifier = 'id_product_attribute';
protected $webserviceParameters = array(
'objectNodeName' => 'combination',
'objectsNodeName' => 'combinations',
@@ -114,14 +114,14 @@ class CombinationCore extends ObjectModel
$fields['available_date'] = pSQL($this->available_date);
return $fields;
}
public function delete()
{
if (!parent::delete() OR $this->deleteAssociations() === false)
return false;
return true;
}
public function deleteAssociations()
{
if (
@@ -132,7 +132,7 @@ class CombinationCore extends ObjectModel
return false;
return true;
}
public function setWsProductOptionValues($values)
{
if ($this->deleteAssociations())
@@ -148,7 +148,7 @@ class CombinationCore extends ObjectModel
}
return false;
}
public function getWsProductOptionValues()
{
$result = Db::getInstance()->executeS('SELECT id_attribute AS id from `'._DB_PREFIX_.'product_attribute_combination` WHERE id_product_attribute = '.(int)$this->id);
@@ -179,7 +179,7 @@ class CombinationCore extends ObjectModel
);
return true;
}
/**
* This method is allow to know if a feature is active
* @since 1.5.0.1
@@ -189,16 +189,16 @@ class CombinationCore extends ObjectModel
{
return Configuration::get('PS_COMBINATION_FEATURE_ACTIVE');
}
/**
* This method is allow to know if a feature is in use
* @since 1.5.0.1
* @return bool
*/
public static function isActuallyUsed()
public static function isCurrentlyUsed()
{
return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
SELECT `id_product_attribute`
FROM `'._DB_PREFIX_.'product_attribute`
');
}
+4 -4
View File
@@ -126,12 +126,12 @@ class CustomizationCore
public static function isFeatureActive()
{
if (self::$feature_active === null)
self::$feature_active = (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
self::$feature_active = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_customization_field`
FROM `'._DB_PREFIX_.'customization_field`
') > 1);
');
return self::$feature_active;
}
}
+35 -35
View File
@@ -28,7 +28,7 @@
class DiscountCore extends ObjectModel
{
public $id;
/** @var integer Customer id only if discount is reserved */
public $id_customer;
@@ -130,7 +130,7 @@ class DiscountCore extends ObjectModel
const PERCENT = 1;
const AMOUNT = 2;
const FREE_SHIPPING = 3;
public function getFields()
{
$this->validateFields();
@@ -227,7 +227,7 @@ class DiscountCore extends ObjectModel
}
/**
*
*
* This method allow to get the customer discount
* @param int $id_lang
* @param int $id_customer
@@ -240,10 +240,10 @@ class DiscountCore extends ObjectModel
{
if (!self::isFeatureActive())
return array();
if (!$cart)
$cart = Context::getContext()->cart;
$sql = '
SELECT d.*, dtl.`name` AS `type`, dl.`description`
FROM `'._DB_PREFIX_.'discount` d
@@ -252,28 +252,28 @@ class DiscountCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'discount_type_lang` dtl ON (dt.`id_discount_type` = dtl.`id_discount_type` AND dtl.`id_lang` = '.(int)($id_lang).')
WHERE (d.`id_customer` = '.(int)$id_customer.'
';
// Group clause
if (Group::isFeatureActive())
$sql .= 'OR d.`id_group` IN (
SELECT `id_group`
FROM `'._DB_PREFIX_.'customer_group` cg
SELECT `id_group`
FROM `'._DB_PREFIX_.'customer_group` cg
WHERE cg.`id_customer` = '.(int)$id_customer.'
)';
else
$sql .= 'OR d.`id_group` = 1';
if ($includeGenericOnes)
$sql .= 'OR (d.`id_customer` = 0 AND d.`id_group` = 0)';
$sql .= ')'; // close parenthsis openned befor d.`id_customer`
if ($active)
$sql .= ' AND d.`active` = 1';
if ($hasStock)
$sql .= ' AND d.`quantity` != 0';
$res = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
foreach ($res as &$discount)
@@ -290,7 +290,7 @@ class DiscountCore extends ObjectModel
}
/**
*
*
* @param int $id_customer
* @return bool
*/
@@ -315,7 +315,7 @@ class DiscountCore extends ObjectModel
{
if (!self::isFeatureActive())
return 0;
if (!$currency)
$currency = Context::getContext()->currency;
if (!$shop)
@@ -330,7 +330,7 @@ class DiscountCore extends ObjectModel
if ($this->usedByCustomer((int)$cart->id_customer) >= $this->quantity_per_user AND !$cart->OrderExists())
return 0;
$date_start = strtotime($this->date_from);
$date_end = strtotime($this->date_to);
if ((time() < $date_start OR time() > $date_end) AND !$cart->OrderExists()) return 0;
@@ -407,7 +407,7 @@ class DiscountCore extends ObjectModel
elseif (!is_array($categories) OR !sizeof($categories))
return false;
Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'discount_category`
DELETE FROM `'._DB_PREFIX_.'discount_category`
WHERE `id_discount`='.(int)$this->id);
foreach($categories AS $category)
{
@@ -417,7 +417,7 @@ class DiscountCore extends ObjectModel
WHERE `id_discount`='.(int)($this->id).' AND `id_category`='.(int)($category));
if (Db::getInstance()->NumRows() == 0)
Db::getInstance()->Execute('
INSERT INTO `'._DB_PREFIX_.'discount_category` (`id_discount`, `id_category`)
INSERT INTO `'._DB_PREFIX_.'discount_category` (`id_discount`, `id_category`)
VALUES('.(int)($this->id).','.(int)($category).')');
}
}
@@ -428,9 +428,9 @@ class DiscountCore extends ObjectModel
return false;
return (bool)Db::getInstance()->getValue('
SELECT `id_discount`
FROM `'._DB_PREFIX_.'discount`
WHERE `name` LIKE \''.pSQL($discountName).'\'
SELECT `id_discount`
FROM `'._DB_PREFIX_.'discount`
WHERE `name` LIKE \''.pSQL($discountName).'\'
AND `id_discount` != '.(int)$id_discount);
}
@@ -469,7 +469,7 @@ class DiscountCore extends ObjectModel
$voucher->minimal = (float)($voucher->value);
$voucher->active = 1;
$voucher->cart_display = 1;
$now = time();
$voucher->date_from = date('Y-m-d H:i:s', $now);
$voucher->date_to = date('Y-m-d H:i:s', $now + (3600 * 24 * 365.25)); /* 1 year */
@@ -496,7 +496,7 @@ class DiscountCore extends ObjectModel
}
/**
*
*
* This method allows to get the vouchers can be shown in order page
* @param int $id_lang
* @param int $id_customer
@@ -506,7 +506,7 @@ class DiscountCore extends ObjectModel
{
if (!self::isFeatureActive())
return array();
$sql = '
SELECT d.`name`, dl.`description`, d.`id_discount`
FROM `'._DB_PREFIX_.'discount` d
@@ -514,21 +514,21 @@ class DiscountCore extends ObjectModel
WHERE d.`active` = 1
AND d.`date_from` <= \''.pSQL(date('Y-m-d H:i:s')).'\' AND d.`date_to` >= \''.pSQL(date('Y-m-d H:i:s')).'\'
AND dl.`id_lang` = '.(int)$id_lang.'
AND d.`cart_display` = 1
AND d.`cart_display` = 1
AND d.`quantity` > 0
AND (
(d.`id_customer` = 0 AND d.`id_group` = 0)';
if ($id_customer)
{
$sql .= ' OR (';
// adding id_customer clause
$sql .= 'd.`id_customer` = '.(int)$id_customer;
if (Group::isFeatureActive())
$sql .= '
$sql .= '
OR d.`id_group` IN (
SELECT cg.`id_group`
FROM `'._DB_PREFIX_.'customer_group` cg
SELECT cg.`id_group`
FROM `'._DB_PREFIX_.'customer_group` cg
WHERE cg.`id_customer` = '.(int)$id_customer.'
)';
else
@@ -537,7 +537,7 @@ class DiscountCore extends ObjectModel
}
else
$sql .= ' OR d.`id_group` = 1';
$sql .= ')'; // close parenthesis openned above
return Db::getInstance()->ExecuteS($sql);
@@ -571,7 +571,7 @@ class DiscountCore extends ObjectModel
{
return Db::getInstance()->getRow('SELECT * FROM `'._DB_PREFIX_.'discount` WHERE `id_discount` = '.(int)$id_discount);
}
/**
* This metohd is allow to know if a feature is used or active
* @since 1.5.0.1
@@ -580,11 +580,11 @@ class DiscountCore extends ObjectModel
public static function isFeatureActive()
{
if (self::$feature_active === null)
self::$feature_active = (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
FROM `'._DB_PREFIX_.'discount`
self::$feature_active = Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_discount`
FROM `'._DB_PREFIX_.'discount`
WHERE `active` = 1
') > 0);
');
return self::$feature_active;
}
}
+16 -16
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -31,7 +31,7 @@ class GroupCore extends ObjectModel
/** @var string Lastname */
public $name;
/** @var string Reduction */
public $reduction;
@@ -49,7 +49,7 @@ class GroupCore extends ObjectModel
protected $fieldsRequired = array('price_display_method');
protected $fieldsSize = array();
protected $fieldsValidate = array('reduction' => 'isFloat', 'price_display_method' => 'isPriceDisplayMethod');
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 32);
protected $fieldsValidateLang = array('name' => 'isGenericName');
@@ -60,9 +60,9 @@ class GroupCore extends ObjectModel
protected static $_cacheReduction = array();
protected static $_groupPriceDisplayMethod = array();
protected static $feature_active = null;
protected $webserviceParameters = array();
public function getFields()
{
$this->validateFields();
@@ -75,14 +75,14 @@ class GroupCore extends ObjectModel
return $fields;
}
public function getTranslationsFieldsChild()
{
if (!$this->validateFieldsLang())
return false;
return $this->getTranslationsFields(array('name'));
}
public static function getGroups($id_lang)
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
@@ -91,7 +91,7 @@ class GroupCore extends ObjectModel
LEFT JOIN `'._DB_PREFIX_.'group_lang` AS gl ON (g.`id_group` = gl.`id_group` AND gl.`id_lang` = '.(int)($id_lang).')
ORDER BY g.`id_group` ASC');
}
public function getCustomers($count = false, $start = 0, $limit = 0)
{
if ($count)
@@ -99,18 +99,18 @@ class GroupCore extends ObjectModel
SELECT COUNT(*)
FROM `'._DB_PREFIX_.'customer_group` cg
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (cg.`id_customer` = c.`id_customer`)
WHERE cg.`id_group` = '.(int)$this->id.'
WHERE cg.`id_group` = '.(int)$this->id.'
AND c.`deleted` != 1');
return Db::getInstance()->ExecuteS('
SELECT cg.`id_customer`, c.*
FROM `'._DB_PREFIX_.'customer_group` cg
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (cg.`id_customer` = c.`id_customer`)
WHERE cg.`id_group` = '.(int)$this->id.'
AND c.`deleted` != 1
WHERE cg.`id_group` = '.(int)$this->id.'
AND c.`deleted` != 1
ORDER BY cg.`id_customer` ASC
'.($limit > 0 ? 'LIMIT '.(int)$start.', '.(int)$limit : ''));
}
public static function getReduction($id_customer = NULL)
{
if (!isset(self::$_cacheReduction['customer'][(int)$id_customer]))
@@ -168,7 +168,7 @@ class GroupCore extends ObjectModel
}
return false;
}
/**
* This method is allow to know if a feature is used or active
* @since 1.5.0.1
@@ -177,10 +177,10 @@ class GroupCore extends ObjectModel
public static function isFeatureActive()
{
if (self::$feature_active === null)
self::$feature_active = (Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
self::$feature_active = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT `id_group`
FROM `'._DB_PREFIX_.'group`
') > 1);
');
return self::$feature_active;
}
}
+8 -8
View File
@@ -36,7 +36,7 @@ class PackCore extends Product
{
if (!self::isFeatureActive())
return false;
if (!array_key_exists($id_product, self::$cacheIsPack))
{
$result = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'pack WHERE id_product_pack = '.(int)($id_product));
@@ -49,7 +49,7 @@ class PackCore extends Product
{
if (!self::isFeatureActive())
return false;
if (!array_key_exists($id_product, self::$cacheIsPacked))
{
$result = Db::getInstance()->getValue('SELECT COUNT(*) FROM '._DB_PREFIX_.'pack WHERE id_product_item = '.(int)($id_product));
@@ -72,7 +72,7 @@ class PackCore extends Product
{
if (!self::isFeatureActive())
return array();
if (array_key_exists($id_product, self::$cachePackItems))
return self::$cachePackItems[$id_product];
$result = Db::getInstance()->ExecuteS('SELECT id_product_item, quantity FROM '._DB_PREFIX_.'pack where id_product_pack = '.(int)($id_product));
@@ -91,7 +91,7 @@ class PackCore extends Product
{
if (!self::isFeatureActive())
return true;
$items = self::getItems((int)($id_product), Configuration::get('PS_LANG_DEFAULT'));
foreach ($items AS $item)
if ($item->quantity < $item->pack_quantity AND !$item->isAvailableWhenOutOfStock((int)($item->out_of_stock)))
@@ -103,7 +103,7 @@ class PackCore extends Product
{
if (!self::isFeatureActive())
return array();
$sql = 'SELECT p.*, pl.*, i.`id_image`, il.`legend`, t.`rate`, cl.`name` AS category_default, a.quantity AS pack_quantity
FROM `'._DB_PREFIX_.'pack` a
LEFT JOIN `'._DB_PREFIX_.'product` p ON p.id_product = a.id_product_item
@@ -132,7 +132,7 @@ class PackCore extends Product
{
if (!self::isFeatureActive())
return array();
$packs = Db::getInstance()->getValue('
SELECT GROUP_CONCAT(a.`id_product_pack`)
FROM `'._DB_PREFIX_.'pack` a
@@ -196,7 +196,7 @@ class PackCore extends Product
// If return query result, a non-pack product will return false
return true;
}
/**
* This method is allow to know if a feature is used or active
* @since 1.5.0.1
@@ -206,7 +206,7 @@ class PackCore extends Product
{
if (self::$feature_active === null)
self::$feature_active = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
SELECT `id_pack`
FROM `'._DB_PREFIX_.'pack`
');
return self::$feature_active;
+12 -12
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -29,19 +29,19 @@ class ProductDownloadCore extends ObjectModel
{
/** @var integer Product id which download belongs */
public $id_product;
/** @var string DisplayFilename the name which appear */
public $display_filename;
/** @var string PhysicallyFilename the name of the file on hard disk */
public $physically_filename;
/** @var string DateDeposit when the file is upload */
public $date_deposit;
/** @var string DateExpiration deadline of the file */
public $date_expiration;
/** @var string NbDaysAccessible how many days the customer can access to file */
public $nb_days_accessible;
@@ -79,9 +79,9 @@ class ProductDownloadCore extends ObjectModel
protected $table = 'product_download';
protected $identifier = 'id_product_download';
protected static $feature_active = null;
/**
* Build a virtual product
*
@@ -92,7 +92,7 @@ class ProductDownloadCore extends ObjectModel
parent::__construct($id_product_download);
// @TODO check if the file is present on hard drive
}
public function delete($deleteFile=false)
{
if ($deleteFile)
@@ -103,7 +103,7 @@ class ProductDownloadCore extends ObjectModel
public function getFields()
{
$this->validateFields();
if (!$this->date_expiration)
$this->date_expiration = '0000-00-00 00:00:00';
@@ -162,15 +162,15 @@ class ProductDownloadCore extends ObjectModel
{
if (!self::isFeatureActive())
return false;
if (array_key_exists($id_product, self::$_productIds))
return self::$_productIds[$id_product];
self::$_productIds[$id_product] = (int)Db::getInstance()->getValue('
SELECT `id_product_download`
FROM `'._DB_PREFIX_.'product_download`
WHERE `id_product` = '.(int)$id_product.' AND `active` = 1');
return self::$_productIds[$id_product];
}
@@ -282,7 +282,7 @@ class ProductDownloadCore extends ObjectModel
{
if (self::$feature_active === null)
self::$feature_active = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
SELECT `id_product_download`
FROM `'._DB_PREFIX_.'product_download`
');
return self::$feature_active;
+37 -37
View File
@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -29,19 +29,19 @@ class SceneCore extends ObjectModel
{
/** @var string Name */
public $name;
/** @var boolean Active Scene */
public $active = true;
/** @var array Zone for image map */
public $zones = array();
/** @var array list of category where this scene is available */
public $categories = array();
/** @var array Products */
public $products;
protected $table = 'scene';
protected $identifier = 'id_scene';
@@ -50,27 +50,27 @@ class SceneCore extends ObjectModel
protected $fieldsRequiredLang = array('name');
protected $fieldsSizeLang = array('name' => 100);
protected $fieldsValidateLang = array('name' => 'isGenericName');
protected static $feature_active = null;
public function __construct($id = NULL, $id_lang = NULL, $liteResult = true, $hideScenePosition = false)
{
parent::__construct((int)($id), (int)($id_lang));
if (!$liteResult)
$this->products = $this->getProducts(true, (int)($id_lang), false);
$this->products = $this->getProducts(true, (int)($id_lang), false);
if ($hideScenePosition)
$this->name = Scene::hideScenePosition($this->name);
$this->image_dir = _PS_SCENE_IMG_DIR_;
}
public function getFields()
{
$this->validateFields();
$fields['active'] = (int)($this->active);
return $fields;
}
/**
* Check then return multilingual fields for database interaction
*
@@ -80,8 +80,8 @@ class SceneCore extends ObjectModel
{
$this->validateFieldsLang();
return $this->getTranslationsFields(array('name'));
}
}
public function update($nullValues = false)
{
if (!$this->updateZoneProducts())
@@ -90,17 +90,17 @@ class SceneCore extends ObjectModel
return false;
return parent::update($nullValues);
}
public function add($autodate = true, $nullValues = false)
{
if (!empty($this->zones))
$this->addZoneProducts($this->zones);
if (!empty($this->categories))
$this->addCategories($this->categories);
return parent::add($autodate, $nullValues);
}
public function delete()
{
$this->deleteZoneProducts();
@@ -108,12 +108,12 @@ class SceneCore extends ObjectModel
if (parent::delete())
return $this->deleteImage();
}
public function deleteImage()
{
if (parent::deleteImage())
{
if (file_exists($this->image_dir.'thumbs/'.$this->id.'-thumb_scene.'.$this->image_format)
if (file_exists($this->image_dir.'thumbs/'.$this->id.'-thumb_scene.'.$this->image_format)
&& !unlink($this->image_dir.'thumbs/'.$this->id.'-thumb_scene.'.$this->image_format))
return false;
}
@@ -121,7 +121,7 @@ class SceneCore extends ObjectModel
return false;
return true;
}
public function addCategories($categories)
{
$result = true;
@@ -132,14 +132,14 @@ class SceneCore extends ObjectModel
}
return $result;
}
public function deleteCategories()
{
return Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'scene_category`
DELETE FROM `'._DB_PREFIX_.'scene_category`
WHERE `id_scene` = '.(int)($this->id));
}
public function updateCategories()
{
if (!$this->deleteCategories())
@@ -148,7 +148,7 @@ class SceneCore extends ObjectModel
return false;
return true;
}
public function addZoneProducts($zones)
{
$result = true;
@@ -161,14 +161,14 @@ class SceneCore extends ObjectModel
}
return $result;
}
public function deleteZoneProducts()
{
return Db::getInstance()->Execute('
DELETE FROM `'._DB_PREFIX_.'scene_products`
WHERE `id_scene` = '.(int)($this->id));
}
public function updateZoneProducts()
{
if (!$this->deleteZoneProducts())
@@ -177,7 +177,7 @@ class SceneCore extends ObjectModel
return false;
return true;
}
/**
* Get all scenes of a category
*
@@ -187,7 +187,7 @@ class SceneCore extends ObjectModel
{
if (!self::isFeatureActive())
return array();
if (!$context)
$context = Context::getContext();
$id_lang = is_null($id_lang) ? $context->language->id : $id_lang;
@@ -202,13 +202,13 @@ class SceneCore extends ObjectModel
.($onlyActive ? ' AND s.active = 1' : '').'
ORDER BY sl.name ASC';
$scenes = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
if (!$liteResult AND $scenes)
foreach($scenes AS &$scene)
$scene = new Scene($scene['id_scene'], $id_lang, false, $hideScenePosition);
return $scenes;
}
/**
* Get all products of this scene
*
@@ -218,17 +218,17 @@ class SceneCore extends ObjectModel
{
if (!self::isFeatureActive())
return array();
if (!$context)
$context = Context::getContext();
$id_lang = is_null($id_lang) ? $context->language->id : $id_lang;
$products = Db::getInstance()->ExecuteS('
SELECT s.*
FROM `'._DB_PREFIX_.'scene_products` s
LEFT JOIN `'._DB_PREFIX_.'product` p ON (p.id_product = s.id_product)
WHERE s.id_scene = '.(int)$this->id.($onlyActive ? ' AND p.active = 1' : ''));
if (!$liteResult AND $products)
foreach ($products AS &$product)
{
@@ -240,7 +240,7 @@ class SceneCore extends ObjectModel
}
return $products;
}
/**
* Get categories where scene is indexed
*
@@ -254,7 +254,7 @@ class SceneCore extends ObjectModel
FROM `'._DB_PREFIX_.'scene_category`
WHERE `id_scene` = '.(int)($id_scene));
}
/**
* Hide scene prefix used for position
*
@@ -265,7 +265,7 @@ class SceneCore extends ObjectModel
{
return preg_replace('/^[0-9]+\./', '', $name);
}
/**
* This method is allow to know if a feature is used or active
* @since 1.5.0.1
@@ -275,7 +275,7 @@ class SceneCore extends ObjectModel
{
if (self::$feature_active === null)
self::$feature_active = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
SELECT `id_scene`
FROM `'._DB_PREFIX_.'scene`
');
return self::$feature_active;
+12 -1
View File
@@ -68,9 +68,16 @@ class SpecificPriceCore extends ObjectModel
public static function getByProductId($id_product)
{
<<<<<<< .mine
return Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
SELECT *
FROM `'._DB_PREFIX_.'specific_price`
WHERE `id_product` = '.(int)$id_product);
=======
return Db::getInstance()->ExecuteS('
SELECT * FROM `'._DB_PREFIX_.'specific_price` WHERE `id_product` = '.(int)$id_product
);
>>>>>>> .r8644
}
public static function getIdsByProductId($id_product)
@@ -206,7 +213,11 @@ class SpecificPriceCore extends ObjectModel
');
$targeted_prices = array();
<<<<<<< .mine
$last_quantity = NULL;
=======
$last_quantity = null;
>>>>>>> .r8644
foreach($res as $specific_price)
{
@@ -297,7 +308,7 @@ class SpecificPriceCore extends ObjectModel
{
if (self::$feature_active === null)
self::$feature_active = (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
SELECT `id_specific_price`
FROM `'._DB_PREFIX_.'specific_price`
');
return self::$feature_active;