Skip to content

Commit

Permalink
[BUG]: LoadByAttribute to include variants (#183)
Browse files Browse the repository at this point in the history
* [Feature]: LoadByAttribute to include variants

* Apply php-cs-fixer changes

Co-authored-by: mcop1 <[email protected]>
  • Loading branch information
mcop1 and mcop1 authored Mar 16, 2022
1 parent 31906cb commit 46317ca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Tool/DataObjectLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
namespace Pimcore\Bundle\DataImporterBundle\Tool;

use Pimcore\Db;
use Pimcore\Model\DataObject;
use Pimcore\Model\Element\ElementInterface;

class DataObjectLoader
Expand Down Expand Up @@ -93,6 +94,7 @@ public function loadByAttribute(string $className,
string $operator = '='): ?ElementInterface
{
$element = null;
$objectTypes = [DataObject::OBJECT_TYPE_VARIANT, DataObject::OBJECT_TYPE_OBJECT];

if ($includeUnpublished) {
$className::setHideUnpublished(false);
Expand All @@ -101,9 +103,9 @@ public function loadByAttribute(string $className,
if ($this->isObjectBrickAttribute($attributeName) === false && $operator === '=') {
$getter = 'getBy' . $attributeName;
if (empty($attributeLanguage) === false) {
$element = $className::$getter($identifier, $attributeLanguage, $limit);
$element = $className::$getter($identifier, $attributeLanguage, $limit, 0, $objectTypes);
} else {
$element = $className::$getter($identifier, $limit);
$element = $className::$getter($identifier, $limit, 0, $objectTypes);
}
} else {
$queryFieldName = $attributeName;
Expand All @@ -116,6 +118,7 @@ public function loadByAttribute(string $className,
if ($limit > 0) {
$conditions['limit'] = $limit;
}
$conditions['objectTypes'] = $objectTypes;
$list = $className::getList($conditions);
$dataObjects = $list->load();
if (empty($dataObjects) === false) {
Expand Down

0 comments on commit 46317ca

Please sign in to comment.