Jump to content

Les Magasins


Recommended Posts

Bonjour,

 

Quand on entre un magasin dans le BO, il y a une rubrique commentaire

 

J'aimerais que cette rubrique s'affiche à droite de distance

 

Afin de vous donenr une idée visuelle:

 

Allez sur http://www.secondevue.fr/stores.php

 

Entrer Arras pusi rechercher

 

Et en bas il y a un tableau reprenant les magasins (ici 1 en l'oxccurence)

 

Comment faire pour afficher lescommentaires saisis dans le BO a coté de la distance?

 

Merci pour votre aide

Link to comment
Share on other sites

Il te faut agir sur 3 choses :

- le fichier stores.tpl du thème, pour y rajouter des colonnes (tout en bas, dans le fichier, rajoute :

<th>{l s='Distance'}</th>

- il faut ensuite modifier le fichier js/stores.js du thème :

Modifie le bloc

clearLocations(markerNodes.length); 
	for (var i = 0; i < markerNodes.length; i++)
	{
		var name = markerNodes[i].getAttribute('name');
		var address = markerNodes[i].getAttribute('address');
		var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
		var other = markerNodes[i].getAttribute('other');
		var distance = parseFloat(markerNodes[i].getAttribute('distance'));
		var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
		var phone = markerNodes[i].getAttribute('phone');
		var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
		var latlng = new google.maps.LatLng(
		parseFloat(markerNodes[i].getAttribute('lat')),
		parseFloat(markerNodes[i].getAttribute('lng')));

		createOption(name, distance, i);
		createMarker(latlng, name, address, addressNoHtml, other, id_store, has_store_picture);
		bounds.extend(latlng);

		$('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td></tr>');
		$('#stores-table').show();
	}


en

 

clearLocations(markerNodes.length);
 for (var i = 0; i < markerNodes.length; i++)
 {
  var name = markerNodes[i].getAttribute('name');
  var address = markerNodes[i].getAttribute('address');
var note = markerNodes[i].getAttribute('note');
  var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
  var other = markerNodes[i].getAttribute('other');
  var distance = parseFloat(markerNodes[i].getAttribute('distance'));
  var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
  var phone = markerNodes[i].getAttribute('phone');
  var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
  var latlng = new google.maps.LatLng(
  parseFloat(markerNodes[i].getAttribute('lat')),
  parseFloat(markerNodes[i].getAttribute('lng')));
  createOption(name, distance, i);
  createMarker(latlng, name, address, addressNoHtml, other, id_store, has_store_picture);
  bounds.extend(latlng);
  $('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td><td class="distance">'+note+'</td></tr>');
  $('#stores-table').show();
 }

- le contrôleur. Crée le fichier /override/controllers/StoresController.php et colle y ça :

<?php

class StoresControllerCore extends StoresControllerCore
{
public function preProcess()
{
 global $smarty, $cookie;

 if(!extension_loaded('Dom'))
 {
  $this->errors[] = Tools::displayError('Dom extension is not loaded.');
  $smarty->assign('errors', $this->errors);
 }

 $simplifiedStoreLocator = Configuration::get('PS_STORES_SIMPLIFIED');
 $distanceUnit = Configuration::get('PS_DISTANCE_UNIT');
 if (!in_array($distanceUnit, array('km', 'mi')))
  $distanceUnit = 'km';

 if ($simplifiedStoreLocator)
 {
  $stores = Db::getInstance()->ExecuteS('
  SELECT s.*, cl.name country, st.iso_code state
  FROM '._DB_PREFIX_.'store s
  LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
  LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
  WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang));

  foreach ($stores AS &$store)
   $store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg');
 }
 else
 { 
  if (Tools::getValue('all') == 1)
  { 
   $stores = Db::getInstance()->ExecuteS('
   SELECT s.*, cl.name country, st.iso_code state
   FROM '._DB_PREFIX_.'store s
   LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
   LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
   WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang));
  }
  else
  {
   $distance = (int)(Tools::getValue('radius', 100));
   $multiplicator = ($distanceUnit == 'km' ? 6371 : 3959);

   $stores = Db::getInstance()->ExecuteS('
   SELECT s.*, cl.name country, st.iso_code state,
   ('.(int)($multiplicator).' * acos(cos(radians('.(float)(Tools::getValue('latitude')).')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.(float)(Tools::getValue('longitude')).')) + sin(radians('.(float)(Tools::getValue('latitude')).')) * sin(radians(latitude)))) distance, cl.id_country id_country
   FROM '._DB_PREFIX_.'store s
   LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
   LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
   WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang).'
   HAVING distance < '.(int)($distance).'
   ORDER BY distance ASC
   LIMIT 0,20');
  }
  if (Tools::getValue('ajax') == 1)
  {
   $dom = new DOMDocument('1.0');
   $node = $dom->createElement('markers');
   $parnode = $dom->appendChild($node);
   $days[1] = 'Monday';
   $days[2] = 'Tuesday';
   $days[3] = 'Wednesday';
   $days[4] = 'Thursday';
   $days[5] = 'Friday';
   $days[6] = 'Saturday';
   $days[7] = 'Sunday';
   foreach ($stores AS $store)
   {
 $days_datas = array();
 $node = $dom->createElement('marker');
 $newnode = $parnode->appendChild($node);
 $newnode->setAttribute('name', $store['name']);
 $address =  $this->_processStoreAddress($store);

 $other = '';
 if (!empty($store['hours']))
 {
  $hours = unserialize($store['hours']);
  for ($i = 1; $i < 8; $i++)
  {
   $hours_datas = array();
   $hours_datas['day'] = $days[$i];
   $hours_datas['hours'] = $hours[(int)($i) - 1];
   $days_datas[] = $hours_datas;
  }
  $smarty->assign('days_datas', $days_datas);
  $smarty->assign('id_country', $store['id_country']);

  $other .= self::$smarty->fetch(_PS_THEME_DIR_.'store_infos.tpl');
 }

 $newnode->setAttribute('addressNoHtml', strip_tags(str_replace('<br />', ' ', $address)));
 $newnode->setAttribute('address', $address);
 $newnode->setAttribute('note', $note);
 $newnode->setAttribute('other', $other);
 $newnode->setAttribute('phone', $store['phone']);
 $newnode->setAttribute('id_store', (int)($store['id_store']));
 $newnode->setAttribute('has_store_picture', file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg'));
 $newnode->setAttribute('lat', (float)($store['latitude']));
 $newnode->setAttribute('lng', (float)($store['longitude']));

 if (isset($store['distance']))
  $newnode->setAttribute('distance', (int)($store['distance']));
   }

   header('Content-type: text/xml');
   die($dom->saveXML());
  }
  else
   $smarty->assign('hasStoreIcon', file_exists(dirname(__FILE__).'/../img/logo_stores.gif'));
 }

 $smarty->assign(array('distance_unit' => $distanceUnit, 'simplifiedStoresDiplay' => $simplifiedStoreLocator, 'stores' => $stores, 'mediumSize' => Image::getSize('medium')));
}
}

  • Like 1
Link to comment
Share on other sites

Mon erreur

Fatal error: Cannot redeclare class StoresControllerCore in /homez.52/secondev/www/override/controllers/StoresController.php on line 119

 

Mille excuses, la première ligne de /override/controllers/StoresController.php doit etre :

class StoresController extends StoresControllerCore

 

et pas

 

class StoresControllerCore extends StoresControllerCore

Link to comment
Share on other sites

Dans le fichier js/stores.js de ton thème, il y a une erreur. Au lieu de

function clearLocations(markerNodes.length); 
 for (var i = 0; i < markerNodes.length; i++)
 {
  var name = markerNodes[i].getAttribute('name');
  var address = markerNodes[i].getAttribute('address');
var note = markerNodes[i].getAttribute('note');
  var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
  var other = markerNodes[i].getAttribute('other');
  var distance = parseFloat(markerNodes[i].getAttribute('distance'));
  var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
  var phone = markerNodes[i].getAttribute('phone');
  var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
  var latlng = new google.maps.LatLng(
  parseFloat(markerNodes[i].getAttribute('lat')),
  parseFloat(markerNodes[i].getAttribute('lng')));
  createOption(name, distance, i);
  createMarker(latlng, name, address, addressNoHtml, other, id_store, has_store_picture);
  bounds.extend(latlng);
  $('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td><td class="distance">'+note+'</td></tr>');
  $('#stores-table').show();
 }

 

On doit avoir

 

function clearLocations(markerNodes.length) {
 for (var i = 0; i < markerNodes.length; i++)
 {
  var name = markerNodes[i].getAttribute('name');
  var address = markerNodes[i].getAttribute('address');
var note = markerNodes[i].getAttribute('note');
  var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
  var other = markerNodes[i].getAttribute('other');
  var distance = parseFloat(markerNodes[i].getAttribute('distance'));
  var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
  var phone = markerNodes[i].getAttribute('phone');
  var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
  var latlng = new google.maps.LatLng(
  parseFloat(markerNodes[i].getAttribute('lat')),
  parseFloat(markerNodes[i].getAttribute('lng')));
  createOption(name, distance, i);
  createMarker(latlng, name, address, addressNoHtml, other, id_store, has_store_picture);
  bounds.extend(latlng);
  $('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td><td class="distance">'+note+'</td></tr>');
  $('#stores-table').show();
 }
}

Link to comment
Share on other sites

Corrige :

function clearLocations(markerNodes.length) {
 for (var i = 0; i < markerNodes.length; i++)
 {
  var name = markerNodes[i].getAttribute('name');
  var address = markerNodes[i].getAttribute('address');
var note = markerNodes[i].getAttribute('note');
  var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
  var other = markerNodes[i].getAttribute('other');
  var distance = parseFloat(markerNodes[i].getAttribute('distance'));
  var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
  var phone = markerNodes[i].getAttribute('phone');
  var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
  var latlng = new google.maps.LatLng(
  parseFloat(markerNodes[i].getAttribute('lat')),
  parseFloat(markerNodes[i].getAttribute('lng')));
  createOption(name, distance, i);
  createMarker(latlng, name, address, addressNoHtml, other, id_store, has_store_picture);
  bounds.extend(latlng);
  $('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td><td class="distance">'+note+'</td></tr>');
  $('#stores-table').show();
 }
}

function searchLocationsNear(center)
{
var radius = document.getElementById('radiusSelect').value;
var localSearchUrl = searchUrl + '?ajax=1&latitude=' + center.lat() + '&longitude=' + center.lng() + '&radius=' + radius;
downloadUrl(localSearchUrl, function(data) {
	var xml = parseXml(data);
	var markerNodes = xml.documentElement.getElementsByTagName('marker');
	var bounds = new google.maps.LatLngBounds();

	clearLocations(markerNodes.length); 
	for (var i = 0; i < markerNodes.length; i++)
	{
		var name = markerNodes[i].getAttribute('name');
		var address = markerNodes[i].getAttribute('address');
		var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
		var other = markerNodes[i].getAttribute('other');
		var distance = parseFloat(markerNodes[i].getAttribute('distance'));
		var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
		var phone = markerNodes[i].getAttribute('phone');
		var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
		var latlng = new google.maps.LatLng(
		parseFloat(markerNodes[i].getAttribute('lat')),
		parseFloat(markerNodes[i].getAttribute('lng')));

		createOption(name, distance, i);
		createMarker(latlng, name, address, addressNoHtml, other, id_store, has_store_picture);
		bounds.extend(latlng);

		$('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td></tr>');
		$('#stores-table').show();
	}

	if (markerNodes.length)
	{
		map.fitBounds(bounds);
		var listener = google.maps.event.addListener(map, "idle", function() { 
			if (map.getZoom() > 13) map.setZoom(13);
			google.maps.event.removeListener(listener); 
		});
	}
	locationSelect.style.visibility = 'visible';
	locationSelect.onchange = function() {
		var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
		google.maps.event.trigger(markers[markerNum], 'click');
	};
});
}

 

en

 

function clearLocations(markerNodes) {
 for (var i = 0; i < markerNodes.length; i++)
 {
  var name = markerNodes[i].getAttribute('name');
  var address = markerNodes[i].getAttribute('address');
var note = markerNodes[i].getAttribute('note');
  var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
  var other = markerNodes[i].getAttribute('other');
  var distance = parseFloat(markerNodes[i].getAttribute('distance'));
  var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
  var phone = markerNodes[i].getAttribute('phone');
  var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
  var latlng = new google.maps.LatLng(
  parseFloat(markerNodes[i].getAttribute('lat')),
  parseFloat(markerNodes[i].getAttribute('lng')));
  createOption(name, distance, i);
  createMarker(latlng, name, address, addressNoHtml, other, id_store, has_store_picture);
  bounds.extend(latlng);
  $('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td><td class="distance">'+note+'</td></tr>');
  $('#stores-table').show();
 }
}
function searchLocationsNear(center)
{
var radius = document.getElementById('radiusSelect').value;
var localSearchUrl = searchUrl + '?ajax=1&latitude=' + center.lat() + '&longitude=' + center.lng() + '&radius=' + radius;
downloadUrl(localSearchUrl, function(data) {
 var xml = parseXml(data);
 var markerNodes = xml.documentElement.getElementsByTagName('marker');
 var bounds = new google.maps.LatLngBounds();
 clearLocations(markerNodes);
 for (var i = 0; i < markerNodes.length; i++)
 {
  var name = markerNodes[i].getAttribute('name');
  var address = markerNodes[i].getAttribute('address');
  var addressNoHtml = markerNodes[i].getAttribute('addressNoHtml');
  var other = markerNodes[i].getAttribute('other');
  var distance = parseFloat(markerNodes[i].getAttribute('distance'));
  var id_store = parseFloat(markerNodes[i].getAttribute('id_store'));
  var phone = markerNodes[i].getAttribute('phone');
  var has_store_picture = markerNodes[i].getAttribute('has_store_picture');
  var latlng = new google.maps.LatLng(
  parseFloat(markerNodes[i].getAttribute('lat')),
  parseFloat(markerNodes[i].getAttribute('lng')));
  createOption(name, distance, i);
  createMarker(latlng, name, address, addressNoHtml, other, id_store, has_store_picture);
  bounds.extend(latlng);
  $('#stores-table tr:last').after('<tr class="node"><td class="num">'+parseInt(i + 1)+'</td><td><b>'+name+'</b>'+(has_store_picture == 1 ? '<br /><img src="'+img_store_dir+parseInt(id_store)+'-medium.jpg" alt="" />' : '')+'</td><td>'+address+(phone != '' ? '<br /><br />'+translation_4+' '+phone : '')+'</td><td class="distance">'+distance+' '+distance_unit+'</td></tr>');
  $('#stores-table').show();
 }
 if (markerNodes.length)
 {
  map.fitBounds(bounds);
  var listener = google.maps.event.addListener(map, "idle", function() {
   if (map.getZoom() > 13) map.setZoom(13);
   google.maps.event.removeListener(listener);
  });
 }
 locationSelect.style.visibility = 'visible';
 locationSelect.onchange = function() {
  var markerNum = locationSelect.options[locationSelect.selectedIndex].value;
  google.maps.event.trigger(markers[markerNum], 'click');
 };
});
}

Link to comment
Share on other sites

Remplace le contenu de ton /override/controllers/StoresController.php par ça :

<?php

class StoresController extends StoresControllerCore
{
public $php_self = 'stores.php';
public function preProcess()
{
 global $smarty, $cookie;

 if(!extension_loaded('Dom'))
 {
  $this->errors[] = Tools::displayError('Dom extension is not loaded.');
  $smarty->assign('errors', $this->errors);
 }

 $simplifiedStoreLocator = Configuration::get('PS_STORES_SIMPLIFIED');
 $distanceUnit = Configuration::get('PS_DISTANCE_UNIT');
 if (!in_array($distanceUnit, array('km', 'mi')))
  $distanceUnit = 'km';

 if ($simplifiedStoreLocator)
 {
  $stores = Db::getInstance()->ExecuteS('
  SELECT s.*, cl.name country, st.iso_code state
  FROM '._DB_PREFIX_.'store s
  LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
  LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
  WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang));

  foreach ($stores AS &$store)
   $store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg');
 }
 else
 { 
  if (Tools::getValue('all') == 1)
  { 
   $stores = Db::getInstance()->ExecuteS('
   SELECT s.*, cl.name country, st.iso_code state
   FROM '._DB_PREFIX_.'store s
   LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
   LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
   WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang));
  }
  else
  {
   $distance = (int)(Tools::getValue('radius', 100));
   $multiplicator = ($distanceUnit == 'km' ? 6371 : 3959);

   $stores = Db::getInstance()->ExecuteS('
   SELECT s.*, cl.name country, st.iso_code state,
   ('.(int)($multiplicator).' * acos(cos(radians('.(float)(Tools::getValue('latitude')).')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.(float)(Tools::getValue('longitude')).')) + sin(radians('.(float)(Tools::getValue('latitude')).')) * sin(radians(latitude)))) distance, cl.id_country id_country
   FROM '._DB_PREFIX_.'store s
   LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
   LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
   WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang).'
   HAVING distance < '.(int)($distance).'
   ORDER BY distance ASC
   LIMIT 0,20');
  }
  if (Tools::getValue('ajax') == 1)
  {
   $dom = new DOMDocument('1.0');
   $node = $dom->createElement('markers');
   $parnode = $dom->appendChild($node);
   $days[1] = 'Monday';
   $days[2] = 'Tuesday';
   $days[3] = 'Wednesday';
   $days[4] = 'Thursday';
   $days[5] = 'Friday';
   $days[6] = 'Saturday';
   $days[7] = 'Sunday';
   foreach ($stores AS $store)
   {
 $days_datas = array();
 $node = $dom->createElement('marker');
 $newnode = $parnode->appendChild($node);
 $newnode->setAttribute('name', $store['name']);
 $address =  $this->_processStoreAddress($store);

 $other = '';
 if (!empty($store['hours']))
 {
  $hours = unserialize($store['hours']);
  for ($i = 1; $i < 8; $i++)
  {
   $hours_datas = array();
   $hours_datas['day'] = $days[$i];
   $hours_datas['hours'] = $hours[(int)($i) - 1];
   $days_datas[] = $hours_datas;
  }
  $smarty->assign('days_datas', $days_datas);
  $smarty->assign('id_country', $store['id_country']);

  $other .= self::$smarty->fetch(_PS_THEME_DIR_.'store_infos.tpl');
 }

 $newnode->setAttribute('addressNoHtml', strip_tags(str_replace('<br />', ' ', $address)));
 $newnode->setAttribute('address', $address);
 $newnode->setAttribute('other', $other);
 $newnode->setAttribute('note', $note);
 $newnode->setAttribute('phone', $store['phone']);
 $newnode->setAttribute('id_store', (int)($store['id_store']));
 $newnode->setAttribute('has_store_picture', file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg'));
 $newnode->setAttribute('lat', (float)($store['latitude']));
 $newnode->setAttribute('lng', (float)($store['longitude']));

 if (isset($store['distance']))
  $newnode->setAttribute('distance', (int)($store['distance']));
   }

   header('Content-type: text/xml');
   die($dom->saveXML());
  }
  else
   $smarty->assign('hasStoreIcon', file_exists(dirname(__FILE__).'/../img/logo_stores.gif'));
 }

 $smarty->assign(array('distance_unit' => $distanceUnit, 'simplifiedStoresDiplay' => $simplifiedStoreLocator, 'stores' => $stores, 'mediumSize' => Image::getSize('medium')));
}
public function _processStoreAddress($store)
{
 $ignore_field = array(
 'firstname' =>1
 , 'lastname' =>1
   );
 $out = '';
 $out_datas = array();
 $address_datas = AddressFormat::getOrderedAddressFields($store['id_country'], false, true);
 $state = (isset($store['id_state'])) ? new State($store['id_state']) : NULL;

 foreach ($address_datas as $data_line)
 {
  $data_fields = explode(' ', $data_line);
  $adr_out = array();

  $data_fields_mod = false;
  foreach ($data_fields as $field_item)
  {
   $field_item = trim($field_item);
   if (!isset($ignore_field[$field_item])  && !empty($store[$field_item]) && $store[$field_item] != '')
   {
 $adr_out[] = ($field_item == "city" && $state && isset($state->iso_code) && strlen($state->iso_code)) ?
  $store[$field_item].', '.$state->iso_code : $store[$field_item];
 $data_fields_mod = true;
   }
  }
  if ($data_fields_mod)
   $out_datas[] = implode(' ', $adr_out);
 }
 $out = implode('<br />', $out_datas);
 return $out;
}
}

Link to comment
Share on other sites

Remplace le contenu du fichier override/classes/StoresController.php par ça :

<?php
class StoresController extends StoresControllerCore
{
public $php_self = 'stores.php';
public function preProcess()
{
 global $smarty, $cookie;

 if(!extension_loaded('Dom'))
 {
  $this->errors[] = Tools::displayError('Dom extension is not loaded.');
  $smarty->assign('errors', $this->errors);
 }

 $simplifiedStoreLocator = Configuration::get('PS_STORES_SIMPLIFIED');
 $distanceUnit = Configuration::get('PS_DISTANCE_UNIT');
 if (!in_array($distanceUnit, array('km', 'mi')))
  $distanceUnit = 'km';

 if ($simplifiedStoreLocator)
 {
  $stores = Db::getInstance()->ExecuteS('
  SELECT s.*, cl.name country, st.iso_code state
  FROM '._DB_PREFIX_.'store s
  LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
  LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
  WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang));

  foreach ($stores AS &$store)
   $store['has_picture'] = file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg');
 }
 else
 {
  if (Tools::getValue('all') == 1)
  {
   $stores = Db::getInstance()->ExecuteS('
   SELECT s.*, cl.name country, st.iso_code state
   FROM '._DB_PREFIX_.'store s
   LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
   LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
   WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang));
  }
  else
  {
   $distance = (int)(Tools::getValue('radius', 100));
   $multiplicator = ($distanceUnit == 'km' ? 6371 : 3959);

   $stores = Db::getInstance()->ExecuteS('
   SELECT s.*, cl.name country, st.iso_code state,
   ('.(int)($multiplicator).' * acos(cos(radians('.(float)(Tools::getValue('latitude')).')) * cos(radians(latitude)) * cos(radians(longitude) - radians('.(float)(Tools::getValue('longitude')).')) + sin(radians('.(float)(Tools::getValue('latitude')).')) * sin(radians(latitude)))) distance, cl.id_country id_country
   FROM '._DB_PREFIX_.'store s
   LEFT JOIN '._DB_PREFIX_.'country_lang cl ON (cl.id_country = s.id_country)
   LEFT JOIN '._DB_PREFIX_.'state st ON (st.id_state = s.id_state)
   WHERE s.active = 1 AND cl.id_lang = '.(int)($cookie->id_lang).'
   HAVING distance < '.(int)($distance).'
   ORDER BY distance ASC
   LIMIT 0,20');
  }
  if (Tools::getValue('ajax') == 1)
  {
   $dom = new DOMDocument('1.0');
   $node = $dom->createElement('markers');
   $parnode = $dom->appendChild($node);
   $days[1] = 'Monday';
   $days[2] = 'Tuesday';
   $days[3] = 'Wednesday';
   $days[4] = 'Thursday';
   $days[5] = 'Friday';
   $days[6] = 'Saturday';
   $days[7] = 'Sunday';
   foreach ($stores AS $store)
   {
	 $days_datas = array();
	 $node = $dom->createElement('marker');
	 $newnode = $parnode->appendChild($node);
	 $newnode->setAttribute('name', $store['name']);
	 $address =  $this->_processStoreAddress($store);
	 $other = '';
	 if (!empty($store['hours']))
	 {
	  $hours = unserialize($store['hours']);
	  for ($i = 1; $i < 8; $i++)
	  {
	   $hours_datas = array();
	   $hours_datas['day'] = $days[$i];
	   $hours_datas['hours'] = $hours[(int)($i) - 1];
	   $days_datas[] = $hours_datas;
	  }
	  $smarty->assign('days_datas', $days_datas);
	  $smarty->assign('id_country', $store['id_country']);

	  $other .= self::$smarty->fetch(_PS_THEME_DIR_.'store_infos.tpl');
	 }

	 $newnode->setAttribute('addressNoHtml', strip_tags(str_replace('<br />', ' ', $address)));
	 $newnode->setAttribute('address', $address);
	 $newnode->setAttribute('other', $other);
	 $newnode->setAttribute('note', $store['note']);
	 $newnode->setAttribute('phone', $store['phone']);
	 $newnode->setAttribute('id_store', (int)($store['id_store']));
	 $newnode->setAttribute('has_store_picture', file_exists(_PS_STORE_IMG_DIR_.(int)($store['id_store']).'.jpg'));
	 $newnode->setAttribute('lat', (float)($store['latitude']));
	 $newnode->setAttribute('lng', (float)($store['longitude']));

	 if (isset($store['distance']))
	  $newnode->setAttribute('distance', (int)($store['distance']));
   }

   header('Content-type: text/xml');
   die($dom->saveXML());
  }
  else
   $smarty->assign('hasStoreIcon', file_exists(dirname(__FILE__).'/../img/logo_stores.gif'));
 }

 $smarty->assign(array('distance_unit' => $distanceUnit, 'simplifiedStoresDiplay' => $simplifiedStoreLocator, 'stores' => $stores, 'mediumSize' => Image::getSize('medium')));
}
public function _processStoreAddress($store)
{
 $ignore_field = array(
	 'firstname' =>1
	 , 'lastname' =>1
   );
 $out = '';
 $out_datas = array();
 $address_datas = AddressFormat::getOrderedAddressFields($store['id_country'], false, true);
 $state = (isset($store['id_state'])) ? new State($store['id_state']) : NULL;

 foreach ($address_datas as $data_line)
 {
  $data_fields = explode(' ', $data_line);
  $adr_out = array();

  $data_fields_mod = false;
  foreach ($data_fields as $field_item)
  {
   $field_item = trim($field_item);
   if (!isset($ignore_field[$field_item])  && !empty($store[$field_item]) && $store[$field_item] != '')
   {
	 $adr_out[] = ($field_item == "city" && $state && isset($state->iso_code) && strlen($state->iso_code)) ?
	  $store[$field_item].', '.$state->iso_code : $store[$field_item];
	 $data_fields_mod = true;
   }
  }
  if ($data_fields_mod)
   $out_datas[] = implode(' ', $adr_out);
 }
 $out = implode('<br />', $out_datas);
 return $out;
}
}

Link to comment
Share on other sites

Impeccable ca marche YESSSSSSSSSSSSSSSSSSSS

Comment faire pour avoir un retour à la ligne

 

Voila ce qui s'affiche:

Nos Tarifs 25 euros Nous ne faisons pas de lentilles

 

Et j'aimerais;

Nos Tarifs 25 euros

Nous ne faisons pas de lentilles

 

Merci Monsieur Samy_R

Link to comment
Share on other sites

Sois IE

Je fas uen recherche sur Rayban et la ca part en sucette

 

SOus Mozilla je fais la meme recherche et j'ai :

 

Notice: Undefined variable: my_region in /homez.52/secondev/www/override/controllers/SearchController.php on line 145

 

Avez vous une idée Samy_R????

Link to comment
Share on other sites

  • 1 year later...

savez-vous par quel mécanisme les champs Latitude et Longitude sont générés dans le formulaire?

en effet, il sont déclarés comme cela dans  renderForm()

public function renderForm(){
[...]
                array(
                    'type' => 'latitude',
                    'label' => $this->l('Latitude / Longitude'),
                    'name' => 'latitude',
                    'required' => true,
                    'size' => 11,
                    'maxlength' => 12,
                    'desc' => $this->l('Store coordinates (e.g. 45.265469/-47.226478)')
                )
[...]
}
Edited by MonVinDirect (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...