crnjohnsen Posted August 25, 2016 Share Posted August 25, 2016 Hola buenas noches tengo una tienda con venta de curso y la dueña me pregunta si se puede restringir categoría para ciertos países porque hay algunos categorías que no quiere que aparezca hay alguna forma?? gracias Link to comment Share on other sites More sharing options...
drasl Posted August 26, 2016 Share Posted August 26, 2016 Tendrías que tocar el controlador, obtener la IP del cliente que está accediendo a la página web, geolocalizar la IP para obtener el país y después no mostrar esa categoría... si tienes conocimientos avanzados sobre Prestashop podrías hacerlo fácil.... si no dominas mucho Prestashop, se me ocurre que podrías hacerlo a través de Javascript, y ocultas vía CSS la categoría en relación a la IP del cliente. Link to comment Share on other sites More sharing options...
ventura Posted August 26, 2016 Share Posted August 26, 2016 Puedes partir desde la geolocalizacion que incluye Prestashop por defecto y sobreescribir el controlador CategoryController para que limite el acceso Link to comment Share on other sites More sharing options...
crnjohnsen Posted August 26, 2016 Author Share Posted August 26, 2016 puff ni idea como se hace eso estoy en nivel novato aun Link to comment Share on other sites More sharing options...
ventura Posted August 28, 2016 Share Posted August 28, 2016 1.Primero activa y configura la geolocalizacion desde Preferencias / Geolocalizacion 2. Crea un archivo CategoryController.php con este contenido <?php class CategoryController extends CategoryControllerCore { public function init() { // Get category ID $id_category = (int)Tools::getValue('id_category'); if (!$id_category || !Validate::isUnsignedId($id_category)) { $this->errors[] = Tools::displayError('Missing category ID'); } // Instantiate category $this->category = new Category($id_category, $this->context->language->id); parent::init(); include_once(_PS_GEOIP_DIR_.'geoipcity.inc'); $gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD); $record = geoip_record_by_addr($gi, Tools::getRemoteAddr()); $countrynotAllowed = array('Croatia', 'Cuba', 'Spain', 'Czech Republic', 'Denmark'); $categorynotAllowed = array('11', '12', '10', '15', '20'); if (in_array($record->country_name,$countrynotAllowed) && in_array($this->category->id,$categorynotAllowed)){ header('HTTP/1.1 403 Forbidden'); header('Status: 403 Forbidden'); $this->display_column_left = false; $this->display_column_right = false; $this->errors[] = Tools::displayError('Category Not Available In Your Country'); $this->customer_access = false; } } } en ese codigo tendrás que editar esta parte con los paises y categorias (IDs) a los que se limitará el acceso, ejemplo: $countrynotAllowed = array('Croatia', 'Cuba', 'Spain', 'Czech Republic', 'Denmark'); $categorynotAllowed = array('11', '12', '10', '15', '20'); una vez editado lo subes a la ruta override/controllers/front/ 3. Elimina este archivo para que se regenere y aplique los cambios contenidos en el override cache/class_index.php 1 Link to comment Share on other sites More sharing options...
nanolibero Posted November 12, 2021 Share Posted November 12, 2021 En 28/8/2016 a las 9:08 AM, ventura dijo: 1.Primero activa y configura la geolocalizacion desde Preferencias / Geolocalizacion 2. Crea un archivo CategoryController.php con este contenido <?php class CategoryController extends CategoryControllerCore { public function init() { // Get category ID $id_category = (int)Tools::getValue('id_category'); if (!$id_category || !Validate::isUnsignedId($id_category)) { $this->errors[] = Tools::displayError('Missing category ID'); } // Instantiate category $this->category = new Category($id_category, $this->context->language->id); parent::init(); include_once(_PS_GEOIP_DIR_.'geoipcity.inc'); $gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD); $record = geoip_record_by_addr($gi, Tools::getRemoteAddr()); $countrynotAllowed = array('Croatia', 'Cuba', 'Spain', 'Czech Republic', 'Denmark'); $categorynotAllowed = array('11', '12', '10', '15', '20'); if (in_array($record->country_name,$countrynotAllowed) && in_array($this->category->id,$categorynotAllowed)){ header('HTTP/1.1 403 Forbidden'); header('Status: 403 Forbidden'); $this->display_column_left = false; $this->display_column_right = false; $this->errors[] = Tools::displayError('Category Not Available In Your Country'); $this->customer_access = false; } } } en ese codigo tendrás que editar esta parte con los paises y categorias (IDs) a los que se limitará el acceso, ejemplo: $countrynotAllowed = array('Croatia', 'Cuba', 'Spain', 'Czech Republic', 'Denmark'); $categorynotAllowed = array('11', '12', '10', '15', '20'); una vez editado lo subes a la ruta override/controllers/front/ 3. Elimina este archivo para que se regenere y aplique los cambios contenidos en el override cache/class_index.php Hola Antonio perdona que reflote un hilo tan viejo me imagino que esto era PS 1.6, porque lo he probado en 1.7 y volviendome loco no lo he logrado me podrías echar una mano como sería esto mismo para PS 1.7 que realmente lo necesitaría muchas gracias Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now