// optimization to Product constructor (stock data is not loaded by default)
This commit is contained in:
@@ -79,6 +79,7 @@ class AdminAttributeGeneratorControllerCore extends AdminController
|
||||
public function postProcess()
|
||||
{
|
||||
$this->product = new Product((int)Tools::getValue('id_product'));
|
||||
$this->product->loadStockData();
|
||||
|
||||
if (isset($_POST['generate']))
|
||||
{
|
||||
|
||||
@@ -924,6 +924,7 @@ class AdminImportControllerCore extends AdminController
|
||||
if (array_key_exists('id', $info) && (int)$info['id'] && Product::existsInDatabase((int)$info['id'], 'product'))
|
||||
{
|
||||
$product = new Product((int)$info['id']);
|
||||
$product->loadStockData();
|
||||
$category_data = Product::getProductCategories((int)$product->id);
|
||||
foreach ($category_data as $tmp)
|
||||
$product->category[] = $tmp;
|
||||
|
||||
@@ -1022,6 +1022,21 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->display = 'list';
|
||||
}
|
||||
|
||||
/**
|
||||
* Override parent to add stock data to object
|
||||
* We don't want to make a "full" product load because of side effects to prices
|
||||
*
|
||||
* @param boolean $opt Return an empty object if load fail
|
||||
* @return object
|
||||
*/
|
||||
protected function loadObject($opt = false)
|
||||
{
|
||||
$result = parent::loadObject($opt);
|
||||
if ($result)
|
||||
$this->object->loadStockData();
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* postProcess handle every checks before saving products information
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user