Exemplo n.º 1
0
 public function displayContent($params)
 {
     $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);
     $this->nbOffers = AphOffer::getOffers('store', $id_shop, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->orderBy, $this->orderWay, true);
     $this->pagination((int) $this->nbOffers);
     // Pagination must be call after "getStoresByProduct"
     $this->offerSort();
     $id_currency = Validate::isLoadedObject(Context::getContext()->currency) ? (int) Context::getContext()->currency->id : (int) Configuration::get('PS_CURRENCY_DEFAULT');
     $offers = AphOffer::getOffers('store', $id_shop, Context::getContext()->language->id, true, NULL, (int) Configuration::get('APH_OFFERS_PER_PAGE'), $this->orderBy, $this->orderWay);
     foreach ($offers as &$offer) {
         $offer = new AphOffer($offer['id_offer'], (int) Context::getContext()->language->id, (int) $id_shop);
         $offer['price_from'] = Tools::displayPrice($offer->price_wt, $id_currency);
         error_log($o->reduction . ' ' . $o->id);
         $offer['new_price'] = $o->price_wt < 0 ? $o->reduction_type == 'percentage' ? '-' . intval(round($o->reduction)) . '%' : '-' . Tools::displayPrice($o['reduction'], (int) Context::getContext()->currency->id) : Tools::displayPrice($o->price_wt, (int) Context::getContext()->currency->id) . ' ';
         $offer['url'] = Context::getContext()->link->getModuleLink('blockoffers', 'offer', array('aof' => $offer['link_rewrite'], 'ido' => $offer['id_offer']));
         $offer['img_link_rewrite'] = Tools::link_rewrite($offer['legend']);
     }
     $this->context->smarty->assign(array('offers' => $offers, 'nb_offers' => $this->nbOffers));
     $this->context->controller->addJS($this->_path . 'blockoffer.js');
     return $this->display(__FILE__, 'blockoffers.tpl', $this->getCacheId());
 }
Exemplo n.º 2
0
 public function initContent()
 {
     parent::initContent();
     $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];
     }
     $this->context->smarty->tpl_vars['meta_title']->value = $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) {
             if (Configuration::get('PS_ROOT_CATEGORY') == $category['id_category'] || Configuration::get('PS_HOME_CATEGORY') == $category['id_category']) {
                 continue;
             }
             $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']));
             }
         }
     }
     $this->context->smarty->assign(array('shop' => $shop, 'cover' => $cover, 'images' => $images, 'products_by_category' => $products_by_category));
     $this->context->controller->addCSS('/themes/aphrodinet/css/shop.css', 'all');
     $this->setTemplate('shop.tpl');
 }
Exemplo n.º 3
0
 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());
 }
Exemplo n.º 4
0
 public function ajaxgetProducts()
 {
     $q = Tools::getValue('q');
     $id_shop = (int) Tools::getValue('ids');
     if (!empty($id_shop)) {
         $products = AphStore::getProductsByStore($id_shop, Context::getContext()->language->id, NULL, NULL, 'name', 'asc', false, true);
     } else {
         $products = AphStore::getProductsByStore(Context::getContext()->shop->id, Context::getContext()->language->id, NULL, NULL, 'name', 'asc', false, true);
     }
     $list = array();
     if (is_array($products) and !empty($products)) {
         foreach ($products as $product) {
             if (!empty($q) && stripos($product['name'], $q) !== false) {
                 $list[] = array('id_product' => $product['id_product'], 'name' => $product['name']);
             }
         }
     }
     exit(Tools::jsonEncode(array('found' => !empty($list), 'results' => $list)));
 }
Exemplo n.º 5
0
 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');
 }
Exemplo n.º 6
-1
 public function displayContent()
 {
     $id_product = (int) Tools::getValue('id_product');
     if (!empty($id_product)) {
         $this->nbShops = AphStore::getStoresByProduct($id_product, Context::getContext()->language->id, null, null, $this->orderBy, $this->orderWay, true);
         $this->pagination((int) $this->nbShops);
         // Pagination must be call after "getStoresByProduct"
         $this->shopSort();
         $shops = AphStore::getStoresByProduct($id_product, Context::getContext()->language->id, $this->p, $this->n, $this->orderBy, $this->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']);
             }
         }
     }
     $this->context->smarty->assign(array('shops' => $shops, 'nb_shops' => $this->nbShops));
     $this->context->controller->addJS('blockshops.js');
     //return $this->display(__FILE__, 'blockshops.tpl', $this->getCacheId());
 }