// Use Collection instead of HydrateCollection in several places
This commit is contained in:
@@ -82,8 +82,10 @@ class StockCore extends ObjectModel
|
||||
'price_te' => 'isPrice',
|
||||
);
|
||||
|
||||
protected $table = 'stock';
|
||||
protected $identifier = 'id_stock';
|
||||
public static $definition = array(
|
||||
'table' => 'stock',
|
||||
'identifier' => 'id_stock',
|
||||
);
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
|
||||
@@ -612,22 +612,17 @@ class StockManagerCore implements StockManagerInterface
|
||||
*
|
||||
* @param int $id_product
|
||||
* @param int $id_product_attribute
|
||||
* @return array
|
||||
* @return Collection
|
||||
*/
|
||||
protected function getStockCollection($id_product, $id_product_attribute, $id_warehouse = null, $price_te = null)
|
||||
{
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('s.id_stock, s.physical_quantity, s.usable_quantity, s.price_te, s.id_product, s.id_product_attribute, s.id_warehouse');
|
||||
$query->from('stock s');
|
||||
$query->where('s.id_product = '.(int)$id_product.' AND s.id_product_attribute = '.(int)$id_product_attribute);
|
||||
$stocks = new Collection('Stock');
|
||||
$stocks->where('a.id_product = '.(int)$id_product.' AND a.id_product_attribute = '.(int)$id_product_attribute);
|
||||
if ($id_warehouse)
|
||||
$query->where('s.id_warehouse = '.(int)$id_warehouse);
|
||||
$stocks->where('a.id_warehouse = '.(int)$id_warehouse);
|
||||
if ($price_te)
|
||||
$query->where('s.price_te = '.(float)$price_te);
|
||||
$stocks->where('a.price_te = '.(float)$price_te);
|
||||
|
||||
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
return ObjectModel::hydrateCollection('Stock', $results);
|
||||
return $stocks;
|
||||
}
|
||||
}
|
||||
@@ -297,22 +297,13 @@ class SupplyOrderCore extends ObjectModel
|
||||
/**
|
||||
* Retrieves the product entries collection for the current order
|
||||
*
|
||||
* @return array
|
||||
* @return Collection
|
||||
*/
|
||||
public function getEntriesCollection($id_lang = null)
|
||||
public function getEntriesCollection()
|
||||
{
|
||||
if ($id_lang == null)
|
||||
$id_lang = Context::getContext()->language->id;
|
||||
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('s.*');
|
||||
$query->from('supply_order_detail s');
|
||||
$query->where('s.id_supply_order = '.(int)$this->id);
|
||||
|
||||
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
return ObjectModel::hydrateCollection('SupplyOrderDetail', $results);
|
||||
$details = new Collection('SupplyOrderDetail');
|
||||
$details->where('a.id_supply_order = '.(int)$this->id);
|
||||
return $details;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -187,15 +187,10 @@ class SupplyOrderDetailCore extends ObjectModel
|
||||
'price_with_order_discount_te' => 'isPrice',
|
||||
);
|
||||
|
||||
/**
|
||||
* @var string Database table name
|
||||
*/
|
||||
protected $table = 'supply_order_detail';
|
||||
|
||||
/**
|
||||
* @var string Database ID name
|
||||
*/
|
||||
protected $identifier = 'id_supply_order_detail';
|
||||
public static $definition = array(
|
||||
'table' => 'supply_order_detail',
|
||||
'primary' => 'id_supply_order_detail',
|
||||
);
|
||||
|
||||
/**
|
||||
* @see ObjectModel::getFields()
|
||||
|
||||
@@ -58,8 +58,10 @@ class WarehouseProductLocationCore extends ObjectModel
|
||||
'id_warehouse' => 'isUnsignedId',
|
||||
);
|
||||
|
||||
protected $table = 'warehouse_product_location';
|
||||
protected $identifier = 'id_warehouse_product_location';
|
||||
public static $definition = array(
|
||||
'table' => 'warehouse_product_location',
|
||||
'primary' => 'id_warehouse_product_location',
|
||||
);
|
||||
|
||||
public function getFields()
|
||||
{
|
||||
@@ -122,18 +124,12 @@ class WarehouseProductLocationCore extends ObjectModel
|
||||
*
|
||||
* @param int $id_product
|
||||
* @param int $id_lang
|
||||
* @return array
|
||||
* @return Collection
|
||||
*/
|
||||
public static function getCollection($id_product)
|
||||
{
|
||||
// build query
|
||||
$query = new DbQuery();
|
||||
$query->select('*');
|
||||
$query->from('warehouse_product_location wpl');
|
||||
$query->where('wpl.id_product = '.(int)$id_product);
|
||||
|
||||
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
|
||||
|
||||
return ObjectModel::hydrateCollection('WarehouseProductLocation', $results);
|
||||
$collection = new Collection('WarehouseProductLocation');
|
||||
$collection->where('a.id_product = '.(int)$id_product);
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user