Skip to content

Commit

Permalink
Fix translations of category design theme not being applied
Browse files Browse the repository at this point in the history
  • Loading branch information
cezary-zeglen committed Nov 1, 2018
1 parent 0ddea98 commit f6eb7fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/code/Magento/Catalog/Model/Design.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\Catalog\Model;

use \Magento\Framework\TranslateInterface;

/**
* Catalog Custom Category design Model
*
Expand All @@ -31,6 +33,11 @@ class Design extends \Magento\Framework\Model\AbstractModel
*/
protected $_localeDate;

/**
* @var TranslateInterface
*/
private $translator;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
Expand All @@ -47,10 +54,13 @@ public function __construct(
\Magento\Framework\View\DesignInterface $design,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
array $data = [],
TranslateInterface $translator = null
) {
$this->_localeDate = $localeDate;
$this->_design = $design;
$this->translator = $translator ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(TranslateInterface::class);
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}

Expand All @@ -63,6 +73,7 @@ public function __construct(
public function applyCustomDesign($design)
{
$this->_design->setDesignTheme($design);
$this->translator->loadData(null, true);
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ public function testApplyCustomDesign($theme)
$design = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\DesignInterface::class
);
$translate = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\TranslateInterface::class
);
$this->assertEquals('package', $design->getDesignTheme()->getPackageCode());
$this->assertEquals('theme', $design->getDesignTheme()->getThemeCode());
$this->assertEquals('themepackage/theme', $translate->getTheme());
}

/**
Expand Down

0 comments on commit f6eb7fb

Please sign in to comment.