Skip to content

Commit b0ee6d2

Browse files
committed
Merge pull request #817 from akeneo/PIM-2163
PIM-2163: Fix issue on mass editing scopable fields
2 parents 6d825af + 360a6d5 commit b0ee6d2

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

src/Pim/Bundle/EnrichBundle/MassEditAction/EditCommonAttributes.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Pim\Bundle\FlexibleEntityBundle\Model\AbstractAttribute;
1010
use Pim\Bundle\CatalogBundle\Manager\ProductManager;
1111
use Pim\Bundle\CatalogBundle\Manager\CurrencyManager;
12-
use Pim\Bundle\CatalogBundle\Entity\Channel;
1312
use Pim\Bundle\CatalogBundle\Entity\Family;
1413
use Pim\Bundle\CatalogBundle\Entity\Locale;
1514
use Pim\Bundle\CatalogBundle\Model\Media;
@@ -356,33 +355,33 @@ protected function addValues(AbstractAttribute $attribute)
356355
if ($attribute->isScopable()) {
357356
foreach ($locale->getChannels() as $channel) {
358357
$key = $attribute->getCode().'_'.$channel->getCode();
359-
$this->values[$key] = $this->createValue($attribute, $locale, $channel);
358+
$this->values[$key] = $this->createValue($attribute, $locale->getCode(), $channel->getCode());
360359
}
361360
} else {
362-
$this->values[$attribute->getCode()] = $this->createValue($attribute, $locale);
361+
$this->values[$attribute->getCode()] = $this->createValue($attribute, $locale->getCode());
363362
}
364363
}
365364

366365
/**
367366
* Create a value
368367
*
369368
* @param AbstractAttribute $attribute
370-
* @param Locale $locale
371-
* @param Channel $channel
369+
* @param string $localeCode
370+
* @param string $channelCode
372371
*
373372
* @return ProductValueInterface
374373
*/
375-
protected function createValue(AbstractAttribute $attribute, Locale $locale, Channel $channel = null)
374+
protected function createValue(AbstractAttribute $attribute, $localeCode = null, $channelCode = null)
376375
{
377376
$value = $this->productManager->createProductValue();
378377
$value->setAttribute($attribute);
379378

380379
if ($attribute->isLocalizable()) {
381-
$value->setLocale($locale);
380+
$value->setLocale($localeCode);
382381
}
383382

384-
if ($channel && $attribute->isScopable()) {
385-
$value->setScope($channel->getCode());
383+
if ($attribute->isScopable()) {
384+
$value->setScope($channelCode);
386385
}
387386

388387
if ('pim_catalog_price_collection' === $attribute->getAttributeType()) {

0 commit comments

Comments
 (0)