Единственное, что я не понял вот что...
ТДС “Настройка страницы”
<?php class Shop_Controller_Extend_Show extends Shop_Controller_Show {
public function addMinMaxProperty($aProperties_id) {
$iCurrentShopGroup = intval($this->group);
$oShop = $this->getEntity();
foreach($aProperties_id as $property_id) {
$aPropertyValues = array();
$oProperty = Core_Entity::factory('Property', $property_id);
$oShop_Items = $oShop->Shop_Items;
$this->_applyItemConditionsQueryBuilder($oShop_Items->queryBuilder());
$aShop_Items = $oShop_Items->getAllByShop_Group_Id($iCurrentShopGroup);
foreach($aShop_Items as $oShop_Item) {
$oPropertyValue = $oProperty->getValues($oShop_Item->id, FALSE);
if(isset($oPropertyValue[0])) {
$aPropertyValues[] = $oPropertyValue[0]->value;
}
} if(count($aPropertyValues)) {
$minPropertyValue = min($aPropertyValues);
$maxPropertyValue = max($aPropertyValues);
$this->addEntity(Core::factory('Core_Xml_Entity')
->name('minPropertyValue')
->value($minPropertyValue)
->addAttribute('id', $property_id))
->addEntity(Core::factory('Core_Xml_Entity')
->name('maxPropertyValue')
->value($maxPropertyValue)
->addAttribute('id', $property_id));
}
}
return $this;
}
}
ТДС “Код страницы”
<?php
$Shop_Controller_Show = new Shop_Controller_Extend_Show(Core_Entity::factory('Shop', 37));
$Shop_Controller_Show
->xsl(Core_Entity::factory('Xsl')->getByName('ДиаграммаВидовДревесиныПоТвёрдости'))
->itemsProperties(array(371))
->addMinMaxProperty(array(371))
->limit(999)
->calculateCounts(TRUE);
$Shop_Controller_Show
->shopItems()
->queryBuilder()
->leftJoin('property_value_floats', 'shop_items.id', '=', 'property_value_floats.entity_id', array(array('AND' => array('property_value_floats.property_id', '=', 371))))
->where('property_value_floats.value', '>', 0)
->groupBy('shop_items.id')
->where('shop_items.active', '=', 1)
->clearOrderBy()
->orderBy('property_value_floats.value', 'DESC'); /* в порядке убывания значений с плавающей запятой дополнительного свойства товара с кодом 371 (по твёрдости Янка) */
$Shop_Controller_Show
->show();
?>
Код XSL-шаблона
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE xsl:stylesheet>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:hostcms="http://www.hostcms.ru/" exclude-result-prefixes="hostcms">
<xsl:output xmlns="http://www.w3.org/TR/xhtml1/strict" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" encoding="utf-8" indent="yes" method="html" omit-xml-declaration="no" version="1.0" media-type="text/xml" />
<xsl:decimal-format name="my" decimal-separator="," grouping-separator=" " />
<xsl:template match="/shop">
<h1 class="d-flex justify-content-between fs-2 text-blue-700 font-family-narrow mb-4">Динамическая диаграмма видов древесины по твёрдости Янка
<div><span class="text-muted"><xsl:value-of disable-output-escaping="yes" select="count(shop_item)" /></span>
из <xsl:value-of disable-output-escaping="yes" select="items_total_count" /></div>
</h1>
<table class="table diagram numbered">
<thead>
<tr class="table-secondary">
<th class="text-end p-2 border-4 border-white">№. Наименование</th>
<th class="text-center p-2 border-4 border-white" colspan="2">Твёрдость Янка, кН <span class="float-end text-secondary">lb<sub>f</sub></span></th>
</tr>
</thead>
<tbody>
<xsl:apply-templates select="shop_item" />
</tbody></table>
</xsl:template>
<xsl:template match="shop_item">
<xsl:if test="not(preceding-sibling::shop_item)">
<xsl:for-each select="//shop_item">
<xsl:variable name="value371" select="property_value[property_id = 371]/value" />
<xsl:variable name="max_value371" select="//maxPropertyValue" />
<tr>
<td class="col text-end"><a href="{url}" target="_blank" rel="noopener"><xsl:value-of select="name" /></a></td>
<td class="col-8">
<div class="progress">
<div class="progress-bar" role="progressbar"
style="width: calc({$value371}%/{$max_value371}*100)"
aria-valuenow="{$value371}" aria-valuemin="0" aria-valuemax="{$max_value371}">
<xsl:value-of select="format-number($value371, '#,##', 'my')" />
</div>
</div></td>
<td class="small text-end text-muted">
<xsl:value-of select="format-number(round($value371 * 22.4809)*10, '0', 'my')" />
</td>
</tr>
</xsl:for-each>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
То есть в ТДС передаётся дополнительное свойство с id=371
Цитата:
->itemsProperties(array(371))
->addMinMaxProperty(array(371))
А в XML передаются данные всех дополнительных свойств:
<shop id="37">
…
<items_count>557</items_count>
<items_total_count>557</items_total_count>
…
<minPropertyValue id="371">0.3</minPropertyValue>
<maxPropertyValue id="371">20.6</maxPropertyValue>
…
<total>552</total>
<shop_item_properties>
<property id="367">
<property_dir_id>0</property_dir_id>
<name>Род</name>
<description></description>
<type>1</type>
<default_value></default_value>
<tag_name>genus</tag_name>
<sorting>1</sorting>
<prefix_small_file>small_property_</prefix_small_file>
<prefix_large_file>property_</prefix_large_file>
<watermark_default_use_large_image>0</watermark_default_use_large_image>
<watermark_default_use_small_image>0</watermark_default_use_small_image>
<typograph>0</typograph>
<trailing_punctuation>0</trailing_punctuation>
<multiple>0</multiple>
<indexing>1</indexing>
<obligatory>1</obligatory>
<prefix></prefix>
<filter>1</filter>
<show_in_group>1</show_in_group>
<show_in_item>1</show_in_item>
</property>
<property id="368">
…
</property>
<property id="369">
…
</property>
<property id="370">
…
<shop_measure id="30">
<name>кг/м³</name>
<description>килограмм на метр кубический</description>
<okei>0</okei>
</shop_measure>
</property>
<property id="371">
…
<shop_measure id="31">
<name>кН</name>
<description>килоньютон (kilonewton - kN)</description>
<okei>0</okei>
</shop_measure>
</property>
<property id="372">
…
<shop_measure id="32">
<name>МПа</name>
<description>мегапаскаль (megapascal - MPa)</description>
<okei>0</okei>
</shop_measure>
</property>
<property id="373">
…
<shop_measure id="33">
<name>ГПа</name>
<description>гигапаскаль (gigapascal - GPa)</description>
<okei>0</okei>
</shop_measure>
</property>
<property id="374">
…
<shop_measure id="32">
<name>МПа</name>
<description>мегапаскаль (megapascal - MPa)</description>
<okei>0</okei>
</shop_measure>
</property>
<property id="375">
…
<shop_measure id="34">
<name>%</name>
<description>проценты</description>
<okei>0</okei>
</shop_measure>
</property>
<property id="376">
…
<shop_measure id="34">
<name>%</name>
<description>проценты</description>
<okei>0</okei>
</shop_measure>
</property>
<property id="377">
…
<shop_measure id="34">
<name>%</name>
<description>проценты</description>
<okei>0</okei>
</shop_measure>
</property>
<property id="384">
…
XML очень большой, передаётся всё подряд... Почему так, если я ограничиваю, например, доп.свойства?