public function initContent() { parent::initContent(); $id_product = (int) Tools::getValue('id_product'); if (!empty($id_product)) { $this->nbShops = AphStore::getStoresByProduct($id_product, Context::getContext()->language->id, null, null, $this->module->orderBy, $this->module->orderWay, true); $this->module->pagination((int) $this->nbShops); // Pagination must be call after "getStoresByProduct" $this->module->shopSort(); $shops = AphStore::getStoresByProduct($id_product, Context::getContext()->language->id, $this->module->p, $this->module->n, $this->module->orderBy, $this->module->orderWay); $id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT'); if (!empty($shops)) { foreach ($shops as &$shop) { $product = new Product($id_product, (int) Context::getContext()->language->id, (int) $shop['id_shop']); $shop['price_from'] = Tools::displayPrice($product->price, $id_currency); //$url = !empty($ssl) ? 'https://'.$shop['domain_ssl'] : 'http://'.$shop['domain']; //$shop['url'] = $url.$shop['uri']; $shop['url'] = Context::getContext()->link->getModuleLink('blockshops', 'shop', array('ash' => $shop['virtual_uri'], 'ids' => $shop['id_shop'])); $shop['img_link_rewrite'] = Tools::link_rewrite($shop['legend']); } } } else { $this->nbShops = AphStore::getStores(true, Context::getContext()->language->id, null, null, $this->module->orderBy, $this->module->orderWay, true); $this->module->pagination((int) $this->nbShops); // Pagination must be call after "getStoresByProduct" $this->module->shopSort(); $shops = AphStore::getStores(true, Context::getContext()->language->id, $this->module->p, $this->module->n, $this->module->orderBy, $this->module->orderWay); if (!empty($shops)) { foreach ($shops as &$shop) { //$url = !empty($ssl) ? 'https://'.$shop['domain_ssl'] : 'http://'.$shop['domain']; //$shop['url'] = $url.$shop['uri']; $shop['url'] = Context::getContext()->link->getModuleLink('blockshops', 'shop', array('ash' => $shop['virtual_uri'], 'ids' => $shop['id_shop'])); $shop['img_link_rewrite'] = Tools::link_rewrite($shop['legend']); } } } $this->context->smarty->assign(array('shops' => $shops, 'nb_shops' => $this->nbShops)); $this->context->controller->addJS('blockshops.js'); $this->setTemplate('blockshops.tpl'); }
public function hookdisplayHomeLine4($params) { $shops = AphStore::getStores(true, Context::getContext()->language->id, 1, 3, 'date_add', 'DESC'); foreach ($shops as &$shop) { $shop['url'] = Context::getContext()->link->getModuleLink('blockshops', 'shop', array('ash' => $shop['virtual_uri'], 'ids' => $shop['id_shop'])); $shop['img_link_rewrite'] = Tools::link_rewrite($shop['legend']); } $this->context->smarty->assign(array('shops' => $shops)); return $this->display(__FILE__, 'blocknewshops.tpl', $this->getCacheId()); }
public function ajaxgetLocations() { $q = Tools::getValue('q'); $list = array(); $country = Country::getByIso('IT', Context::getContext()->language->id); $cities = Db::getInstance()->executeS(' SELECT s.id_city, s.name FROM ' . _DB_PREFIX_ . 'city s LEFT JOIN ' . _DB_PREFIX_ . 'country c ON (s.`id_country` = c.`id_country`) WHERE s.id_country = ' . $country . ' ORDER BY s.`name` ASC'); if (is_array($cities) and !empty($cities)) { foreach ($cities as $city) { if (!empty($q) && stripos($city['name'], $q) !== false) { $city['id_object'] = $city['id_city']; $city['type_object'] = 'city'; $list[] = $city; } } } $shops = AphStore::getStores(true, Context::getContext()->language->id, 1, 10, 'name', 'desc'); if (is_array($shops) and !empty($shops)) { foreach ($shops as $shop) { if (!empty($q) && stripos($shop['name'], $q) !== false) { $shop['id_object'] = $shop['id_shop']; $shop['type_object'] = 'shop'; $list[] = $shop; } } } exit(Tools::jsonEncode(array('found' => !empty($list), 'results' => $list))); }