/** * Load list of groups and shops, and cache it * * @param bool $refresh */ public static function cacheShops($refresh = false) { if (!is_null(self::$shops) && !$refresh) { return; } self::$shops = array(); $db = JFactory::getDBO(); $from = ""; $where = ""; $employee = JeproshopContext::getContext()->employee; // If the profile isn't a superAdmin if (JeproshopTools::isLoadedObject($employee, 'employee_id') && $employee->profile_id != _PS_ADMIN_PROFILE_) { $from .= " LEFT JOIN " . $db->quoteName('#__jeproshop_employee_shop') . " AS employee_shop ON employee_shop.shop_id = shop.shop_id"; $where .= " AND employee_shop.employee_id = " . (int) $employee->employee_id; } $query = "SELECT shop_group.*, shop.*, shop_group.name AS group_name, shop.shop_name AS shop_name, "; $query .= " shop.published, shop_url.domain, shop_url.ssl_domain, shop_url.physical_uri, shop_url."; $query .= "virtual_uri FROM " . $db->quoteName('#__jeproshop_shop_group') . " AS shop_group LEFT JOIN "; $query .= $db->quoteName('#__jeproshop_shop') . " AS shop ON shop.shop_group_id = shop_group.shop_group_id "; $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_shop_url') . " AS shop_url ON shop.shop_id ="; $query .= " shop_url.shop_id AND shop_url.main = 1 " . $from . " WHERE shop.deleted = 0 AND shop_group."; $query .= "deleted = 0 " . $where . " ORDER BY shop_group.name, shop.shop_name"; $db->setQuery($query); $results = $db->loadObjectList(); if ($results) { foreach ($results as $row) { if (!isset(self::$shops[$row->shop_group_id])) { self::$shops[$row->shop_group_id] = array('shop_group_id' => $row->shop_group_id, 'name' => $row->group_name, 'share_customer' => $row->share_customer, 'share_order' => $row->share_order, 'share_stock' => $row->share_stock, 'shops' => array()); self::$shops[$row->shop_group_id]['shops'][$row->shop_id] = $row; /*array( 'shop_id' => $row->shop_id, 'shop_group_id' => $row->shop_group_id, 'name' => $row->shop_name, 'theme_id' => $row->theme_id, 'category_id' => $row->category_id, 'domain' => $row->domain, 'ssl_domain' => $row->ssl_domain, 'uri' => $row->physical_uri . $row->virtual_uri, 'published' => $row->published );*/ } } } }