public function hookdisplayHomeLine3($params) { $cities = AphCity::getBestSellersCities(3, Context::getContext()->language->id); $this->context->smarty->assign(array('cities' => $cities)); return $this->display(__FILE__, 'blockbestsellercities.tpl', $this->getCacheId()); }
public function initContent() { parent::initContent(); $specific_price = NULL; $date = Tools::getValue('date'); if (empty($date) || empty($date)) { $date = date('Y-m-d', strtotime('+2 day')); } $id_product = Tools::getValue('id_product'); if (!empty($date)) { $product = new Product($id_product, true, Context::getContext()->language->id, Context::getContext()->shop->id); } if (empty($product)) { $this->setTemplate('availability_no_product.tpl'); error_log(__LINE__); return; } $id_shop = (int) Tools::getValue('ids'); $id_city = (int) Tools::getValue('id_city'); if (empty($id_shop) && empty($id_city)) { $this->setTemplate('availability_no_location.tpl'); error_log(__LINE__); return; } if (!empty($id_shop)) { $shop = NULL; $alias_shop = (int) Tools::getValue('ash'); if (!empty($alias_shop)) { $_s = AphStore::getByAlias($alias_shop, Context::getContext()->language->id); $id_shop = $_s['id_shop']; } else { $id_shop = (int) Tools::getValue('ids'); } $shop = new AphStore($id_shop, Context::getContext()->language->id); $cover = NULL; $images = AphStoreImage::getImages(Context::getContext()->language->id, $id_shop); foreach ($images as &$image) { if (!empty($image['cover'])) { $cover = $image; } } if (empty($cover) && !empty($images)) { $cover = $images[0]; } } if (empty($id_shop) && !empty($id_city)) { $city = AphCity::getCity($id_city); if (empty($city) && empty($id_shop)) { $this->setTemplate('availability_no_city.tpl'); return; } $shops = AphStore::getByCity($id_city, Context::getContext()->language->id); if (empty($shops)) { $shops = array(); $id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT'); $_shops = AphStore::getStoresByProduct($id_product, Context::getContext()->language->id, null, 100000); foreach ($_shops as &$shop) { if ($this->distance($shop['latitude'], $shop['longitude'], $city['latitude'], $city['longitude'], 'K') > Configuration::get('APH_MAX_KM_FAR_AWAY')) { continue; } $product = new Product($id_product, false, (int) Context::getContext()->language->id, (int) $shop['id_shop']); $price = Product::getPriceStatic($id_product, true, 0, 2, null, false, true, 1, false, null, null, null, $specific_price, true, true, Context::getContext(), true, $date); if (empty($price)) { $price = $product->price; } else { $price = $price; } $shop['price_from'] = Tools::displayPrice($price, $id_currency); //$url = !empty($ssl) ? 'https://'.$shop['domain_ssl'] : 'http://'.$shop['domain']; //$shop['url'] = $url.$shop['uri']; $shop['url'] = Context::getContext()->link->getModuleLink('blockmobilecart', 'availability', array('id_product' => $id_product, 'date' => $date, 'ids' => $shop['id_shop'])); $shop['img_link_rewrite'] = Tools::link_rewrite($shop['legend']); $shops[] = $shop; } if (empty($shops)) { $this->context->smarty->assign(array('availability_no_closure_shops' => true)); } else { $this->context->smarty->assign(array('shops' => $shops, 'availability_no_shops' => true, 'availability_no_shops_city' => $city['name'], 'availability_no_shops_km' => Configuration::get('APH_MAX_KM_FAR_AWAY'))); } $this->setTemplate('availability_shops.tpl'); return; } } else { $shop = new AphStore($id_shop, Context::getContext()->language->id); if (empty($shop) && empty($id_city)) { $this->setTemplate('availability_no_shop.tpl'); error_log(__LINE__); return; } // il negozio non offre il servizio $product = new Product($id_product, true, Context::getContext()->language->id, $id_shop); $employees = AphEmployeeProduct::getEmployeesByShopAndProduct($id_shop, $id_product); if (empty($employees)) { $products = AphStore::getProductsByStore($id_shop, Context::getContext()->language->id, 0, 20, 'name', 'asc', $product->id_category_default, true); foreach ($products as &$product) { $p = new Product($product['id_product'], false, (int) Context::getContext()->language->id, $id_shop); $price = Product::getPriceStatic($product['id_product'], true, 0, 2, null, false, true, 1, false, null, null, null, $specific_price, true, true, Context::getContext(), true, $date); if (empty($price)) { $price = $p->price; } else { $price = $price; } $product['price_from'] = Tools::displayPrice($price, $id_currency); } $this->context->smarty->assign(array('shop' => $shop, 'cover' => $cover, 'images' => $images, 'products' => $products, 'token' => Tools::getToken(false))); $this->setTemplate('availability_no_product_for_shop.tpl'); return; } } if (empty($product)) { $this->setTemplate('availability_no_product.tpl'); return; } $this->context->smarty->tpl_vars['meta_title']->value = 'Acquista ' . $product->name . ' presso ' . $shop->name; $this->context->smarty->tpl_vars['meta_description']->value = $shop->meta_description; // $products_by_category = array(); // $categories = Category::getAllCategoriesName(NULL, Context::getContext()->language->id, true); // if (!empty($categories)){ // foreach ($categories as &$category) { // $products = AphStore::getProductsByStore($id_shop, Context::getContext()->language->id, NULL, NULL, 'name', 'desc', $category['id_category'], true); // foreach ($products as &$product) { // if (empty($products_by_category[ $category['id_category'] ])){ // $products_by_category[ $category['id_category'] ] = array( // 'id_category' => $category['id_category'], // 'name' => $category['name'], // 'class' => Tools::link_rewrite($category['name']), // 'products' => array() // ); // } // $products_by_category[ $category['id_category'] ]['products'][ $product['id_product'] ] = array( // 'id_product' => $product['id_product'], // 'name' => $product['name'], // 'link' => Context::getContext()->link->getProductLink((int)$product['id_product'], $product['link_rewrite'], $category['id_category'], $product['ean13']) // ); // } // } // } $jsVars = array(); $jsVars['calendar_params'] = array('ajax' => 1, 'ajaxCall' => 'ajaxshowCalendar', 'id_product' => $id_product, 'ids' => $id_shop, 'date' => $date, 'id_city' => empty($id_city) ? $shop->id_city : $id_city); $this->context->smarty->assign(array('shop' => $shop, 'cover' => $cover, 'images' => $images, 'product' => $product, 'token' => Tools::getToken(false), 'jsVars' => $jsVars)); $this->setTemplate('availability_full.tpl'); }
private function fetchCountries() { // $countryList = array(); // $countryList[] = array('id' => '0', 'name' => $this->l('Choose your country')); // foreach (Country::getCountries($this->context->language->id) as $country) { // $countryList[] = array('id' => $country['id_country'], 'name' => $country['name']); // } // $this->context->smarty->assign( array('countries' => $countryList)); $cityList = array(); $cityList[] = array('id' => '0', 'name' => $this->l('Scegli il comune')); foreach (AphCity::getCities() as $city) { if ($city['id_country'] == $this->id_country) { $cityList[] = array('id' => $city['id_city'], 'name' => $city['name']); } } $this->context->smarty->assign(array('cities' => $cityList)); $statesList = array(); $statesList[] = array('id' => '0', 'name' => $this->l('Scegli la provincia')); foreach (State::getStates($this->context->language->id) as $state) { if ($state['id_country'] == $this->id_country) { $statesList[] = array('id' => $state['id_state'], 'name' => $state['name']); } } $this->context->smarty->assign(array('states' => $statesList)); }