1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00
This commit is contained in:
Mzhelskiy Maxim 2017-01-13 17:19:12 +07:00
parent 7425641e23
commit c42b43a332
2 changed files with 36 additions and 30 deletions

View file

@ -445,13 +445,16 @@ class ModuleProperty extends ModuleORM
*/
if (isset($aFilter['#properties']) and $aFilter['#properties']) {
$aEntitiesId = array();
$aTargetTypes = array();
foreach ($aEntitiesWork as $oEntity) {
$aEntitiesId[] = $oEntity->getId();
$aTargetTypes[] = $oEntity->getPropertyTargetType();
}
$aTargetTypes = array_unique($aTargetTypes);
/**
* Получаем все свойства со значениями для всех объектов
*/
$aResult = $this->oMapper->GetPropertiesValueByTargetArray($sTargetType, $aEntitiesId);
$aResult = $this->oMapper->GetPropertiesValueByTargetArray($aTargetTypes, $aEntitiesId);
if ($aResult) {
/**
* Формируем список свойств и значений

View file

@ -75,11 +75,14 @@ class ModuleProperty_MapperProperty extends Mapper
return $aResult;
}
public function GetPropertiesValueByTargetArray($sTargetType, $aTargetId)
public function GetPropertiesValueByTargetArray($aTargetType, $aTargetId)
{
if (!is_array($aTargetId)) {
$aTargetId = array($aTargetId);
}
if (!is_array($aTargetType)) {
$aTargetType = array($aTargetType);
}
if (!$aTargetId) {
return array();
}
@ -96,12 +99,12 @@ class ModuleProperty_MapperProperty extends Mapper
FROM " . Config::Get('db.table.property') . " AS p
LEFT JOIN " . Config::Get('db.table.property_value') . " as v on ( v.property_id=p.id and v.target_id IN ( ?a ) )
WHERE
p.target_type = ?
p.target_type IN ( ?a )
ORDER BY
p.sort desc ";
$aResult = array();
if ($aRows = $this->oDb->select($sql, $aTargetId, $sTargetType)) {
if ($aRows = $this->oDb->select($sql, $aTargetId, $aTargetType)) {
return $aRows;
}
return $aResult;