This commit is contained in:
dMetzger
2012-08-31 12:16:15 +00:00
parent 75710639d0
commit f5bcab7459
5 changed files with 29 additions and 29 deletions
+2 -2
View File
@@ -103,9 +103,9 @@ class Autoload
{
// request a non Core Class load the associated Core class if exists
if (isset($this->index[$classname.'Core']))
require($this->root_dir.$this->index[$classname.'Core']);
require_once($this->root_dir.$this->index[$classname.'Core']);
if (isset($this->index[$classname]))
require($this->root_dir.$this->index[$classname]);
require_once($this->root_dir.$this->index[$classname]);
}
}
// Call directly ProductCore, ShopCore class
+3 -6
View File
@@ -1350,8 +1350,6 @@ class ProductCore extends ObjectModel
WHERE `id_product` = '.(int)$this->id.'
), \'0\')
WHERE `id_product` = '.(int)$this->id);
}
/**
* Delete product attributes
@@ -4931,11 +4929,10 @@ class ProductCore extends ObjectModel
public function hasAttributesInOtherShops()
{
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT COUNT(*)
return (bool)Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue('
SELECT pa.id_product_attribute
FROM `'._DB_PREFIX_.'product_attribute` pa
LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` pas
ON (pa.`id_product_attribute` = pas.`id_product_attribute`)
LEFT JOIN `'._DB_PREFIX_.'product_attribute_shop` pas ON (pa.`id_product_attribute` = pas.`id_product_attribute`)
WHERE pa.`id_product` = '.(int)$this->id
);
}
+11 -11
View File
@@ -492,15 +492,15 @@ class StockAvailableCore extends ObjectModel
*
* @param int $id_product
* @param int $id_product_attribute Optional
* @param int $id_shop Optional
* @param mixed $id_shop shop id or shop object Optional
*/
public static function removeProductFromStockAvailable($id_product, $id_product_attribute = null, $id_shop = null)
public static function removeProductFromStockAvailable($id_product, $id_product_attribute = null, $shop = null)
{
return Db::getInstance()->execute('
DELETE FROM '._DB_PREFIX_.'stock_available
WHERE id_product = '.(int)$id_product.
($id_product_attribute ? ' AND id_product_attribute = '.(int)$id_product_attribute : '').
StockAvailable::addSqlShopRestriction(null, $id_shop)
StockAvailable::addSqlShopRestriction(null, $shop)
);
}
@@ -585,7 +585,7 @@ class StockAvailableCore extends ObjectModel
*
* @return mixed the DbQuery object or the sql restriction string
*/
public static function addSqlShopRestriction(DbQuery $sql = null, $id_shop = null, $alias = null)
public static function addSqlShopRestriction(DbQuery $sql = null, $shop = null, $alias = null)
{
$context = Context::getContext();
@@ -594,19 +594,19 @@ class StockAvailableCore extends ObjectModel
// if there is no $id_shop, gets the context one
// get shop group too
if ($id_shop === null)
if ($shop === null)
{
if (Shop::getContext() == Shop::CONTEXT_GROUP)
$shop_group = Shop::getContextShopGroup();
else
{
$shop_group = $context->shop->getGroup();
$id_shop = $context->shop->id;
}
$shop = $context->shop;
}
elseif (is_object($shop))
$shop_group = $shop->getGroup();
else
{
$shop = new Shop($id_shop);
$shop = new Shop($shop);
$shop_group = $shop->getGroup();
}
@@ -627,9 +627,9 @@ class StockAvailableCore extends ObjectModel
else
{
if (is_object($sql))
$sql->where(pSQL($alias).'id_shop = '.(int)$id_shop);
$sql->where(pSQL($alias).'id_shop = '.(int)$shop->id);
else
$sql = ' AND '.pSQL($alias).'id_shop = '.(int)$id_shop.' ';
$sql = ' AND '.pSQL($alias).'id_shop = '.(int)$shop->id.' ';
}
return $sql;
@@ -114,7 +114,7 @@ class AdminAttributeGeneratorControllerCore extends AdminController
{
$attributes = Product::getProductAttributesIds($this->product->id);
foreach ($attributes as $attribute)
StockAvailable::removeProductFromStockAvailable($this->product->id, $attribute['id_product_attribute'], $this->context->shop->id);
StockAvailable::removeProductFromStockAvailable($this->product->id, $attribute['id_product_attribute'], $this->context->shop);
}
$this->product->deleteProductAttributes();
+12 -9
View File
@@ -389,15 +389,18 @@ abstract class Controller extends ControllerCore
foreach ($queries as $data)
{
echo $hr.'<b '.$this->getTimeColor($data['time'] * 1000).'>'.round($data['time'] * 1000, 3).' ms</b> '.$data['query'].'<br />in '.$data['file'].':'.$data['line'].'<br />';
$explain = Db::getInstance()->executeS('explain '.$data['query']);
if (stristr($explain[0]['Extra'], 'filesort'))
echo '<b '.$this->getTimeColor($data['time'] * 1000).'>USING FILESORT</b> - ';
$browsed_rows = 1;
foreach ($explain as $row)
$browsed_rows *= $row['rows'];
echo $this->displayRowsBrowsed($browsed_rows);
if (stristr($data['query'], 'group by') && !preg_match('/(avg|count|min|max|group_concat|sum)\s*\(/i', $data['query']))
echo '<br /><b>Useless GROUP BY need to be removed</b>';
if (preg_match('/^\s*select\s+/i', $data['query']))
{
$explain = Db::getInstance()->executeS('explain '.$data['query']);
if (stristr($explain[0]['Extra'], 'filesort'))
echo '<b '.$this->getTimeColor($data['time'] * 1000).'>USING FILESORT</b> - ';
$browsed_rows = 1;
foreach ($explain as $row)
$browsed_rows *= $row['rows'];
echo $this->displayRowsBrowsed($browsed_rows);
if (stristr($data['query'], 'group by') && !preg_match('/(avg|count|min|max|group_concat|sum)\s*\(/i', $data['query']))
echo '<br /><b>Useless GROUP BY need to be removed</b>';
}
}
echo '</div>
<div class="rte" style="text-align:left;padding:8px">