$aPropertyValues = Core_Entity::factory('Property_Value_String')->getAllByProperty_id(184);
foreach($aPropertyValues as $oPropertyValue)
{
if($oPropertyValue->value != ""){
//$gApiKey = "AIzaSyDcd4oHEy6bhlprBIGoeIke0-aJzmgDbfc";
$gApiKey = "AIzaSyCLRVrByWpOukTP0_Irwb6o33nMhmEiCf0";
$adValue = $oPropertyValue->value;
$oAddress = urlencode($adValue);
$sUrl = 'https://maps.googleapis.com/maps/api/geocode/json?key=' . $gApiKey . "&address=" . $oAddress . "&language=ru®ion=RU";
$oAnswer = json_decode(file_get_contents($sUrl));
$iId = $oPropertyValue->entity_id;
$aLat = $oAnswer->results[0]->geometry->location->lat;
$aLng = $oAnswer->results[0]->geometry->location->lng;
$aFormatedAddress = $oAnswer->results[0]->formatted_address;
$Shop_Controller_Show
->addEntity(Core::factory('Core_Xml_Entity')
->name('items_coords')
->addAttribute('id', $iId)
->addEntity(Core::factory('Core_Xml_Entity')->name('lat')->value($aLat))
->addEntity(Core::factory('Core_Xml_Entity')->name('lng')->value($aLng))
->addEntity(Core::factory('Core_Xml_Entity')->name('formated-address')->value($aFormatedAddress))
);
}
}
а в xsl соответственно:
<xsl:template match="shop_item" mode="json">
<xsl:variable name="group" select="shop_group_id"/>
<xsl:variable name="formated-address" select="/shop/items_coords/formated-address"/>
<xsl:variable name="lat" select="/shop/items_coords/lat"/>
<xsl:variable name="lng" select="/shop/items_coords/lng"/>
{
title: "<xsl:value-of disable-output-escaping="yes" select="name"/>",
address: "<xsl:value-of select="$formated-address" /><!--<xsl:value-of disable-output-escaping="yes" select="property_value[tag_name='address']/value"/>, Зеленоград, Москва, Россия-->",
lat: <xsl:value-of select="$lat" />,
lng: <xsl:value-of select="$lng" />,
img: "<xsl:value-of disable-output-escaping="yes" select="dir"/><xsl:value-of disable-output-escaping="yes" select="image_small"/>",
category: "<xsl:value-of select="//shop_group[@id=$group]/name"/>",
icon: "<xsl:value-of select="//shop_group[@id=$group]/property_value[tag_name='icon']/value"/>",
<!--featText: "Fixed Price $99",-->
rating: "<xsl:value-of select="comments_average_grade" />",
link: "<xsl:value-of disable-output-escaping="yes" select="url"/>"
}
<xsl:if test="position() != last()">
<xsl:text>,</xsl:text>
</xsl:if>
</xsl:template>