diff --git a/classes/Tools.php b/classes/Tools.php index 592dc8c9e..123d71a58 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1502,12 +1502,12 @@ class ToolsCore $domains = array(); foreach (ShopUrl::getShopUrls() as $shop_url) { - if (!isset($domains[$shop_url['domain']])) + if (!isset($domains[$shop_url->domain])) $domains[$shop_url['domain']] = array(); - $domains[$shop_url['domain']][] = array( - 'physical' => $shop_url['physical_uri'], - 'virtual' => $shop_url['virtual_uri'], + $domains[$shop_url->domain][] = array( + 'physical' => $shop_url->physical_uri, + 'virtual' => $shop_url->virtual_uri, ); } diff --git a/classes/shop/GroupShop.php b/classes/shop/GroupShop.php index 2f0429adf..8e34e00b2 100644 --- a/classes/shop/GroupShop.php +++ b/classes/shop/GroupShop.php @@ -77,11 +77,11 @@ class GroupShopCore extends ObjectModel public static function getGroupShops($active = true) { - return Db::getInstance()->executeS(' - SELECT * - FROM '._DB_PREFIX_.'group_shop - WHERE `deleted`= 0 AND `active`='.(int)$active - ); + $groups = new Collection('GroupShop'); + $groups->where('deleted = 0'); + if ($active) + $groups->where('active = 1'); + return $groups; } public function delete() diff --git a/classes/shop/ShopUrl.php b/classes/shop/ShopUrl.php index 2e2e89829..0b80cda63 100644 --- a/classes/shop/ShopUrl.php +++ b/classes/shop/ShopUrl.php @@ -80,13 +80,18 @@ class ShopUrlCore extends ObjectModel return $url.$this->physical_uri.$this->virtual_uri; } + /** + * Get list of shop urls + * + * @param bool $id_shop + * @return Collection + */ public static function getShopUrls($id_shop = false) { - $sql = 'SELECT * - FROM '._DB_PREFIX_.'shop_url - WHERE 1 - '.($id_shop ? ' AND id_shop = '.(int)$id_shop : ''); - return Db::getInstance()->executeS($sql); + $urls = new Collection('ShopUrl'); + if ($id_shop) + $urls->where('id_shop = '.(int)$id_shop); + return $urls; } public function setMain() diff --git a/controllers/admin/AdminShopController.php b/controllers/admin/AdminShopController.php index 3d7e5b43b..a41ddfd29 100755 --- a/controllers/admin/AdminShopController.php +++ b/controllers/admin/AdminShopController.php @@ -194,16 +194,25 @@ class AdminShopControllerCore extends AdminController ); } else + { + $options = array(); + foreach (GroupShop::getGroupShops() as $group) + $options[] = array( + 'id_group_shop' => $group->id, + 'name' => $group->name, + ); + $this->fields_form['input'][] = array( 'type' => 'select', 'label' => $this->l('Group Shop:'), 'name' => 'id_group_shop', 'options' => array( - 'query' => GroupShop::getGroupShops(), + 'query' => $options, 'id' => 'id_group_shop', 'name' => 'name' ) ); + } $categories = Category::getCategories($this->context->language->id, false, false); $this->fields_form['input'][] = array(