Translations for the menu#360
Conversation
|
|
||
| // Create store view lookup array | ||
| $storeViewLabels = []; | ||
| $websites = $this->systemStore->getWebsiteCollection(); | ||
| $websiteNames = []; | ||
|
|
||
| // Create website name lookup array | ||
| foreach ($websites as $website) { | ||
| $websiteNames[$website->getId()] = $website->getName(); | ||
| } | ||
|
|
||
| foreach ($this->systemStore->getStoreCollection() as $store) { | ||
| if ($store->isActive()) { | ||
| $websiteName = isset($websiteNames[$store->getWebsiteId()]) | ||
| ? $websiteNames[$store->getWebsiteId()] | ||
| : ''; | ||
| $storeViewLabels[$store->getId()] = [ | ||
| 'value' => $store->getId(), | ||
| 'label' => sprintf('%s -> %s', $websiteName, $store->getName()) | ||
| ]; | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
It looks like duplicate piece of code. I think you can use the function getStoreViews().
| ->setStoreId($storeId) | ||
| ->setTitle($title); | ||
|
|
||
| $this->nodeTranslationRepository->save($translation); |
There was a problem hiding this comment.
Maybe it's worth to wrap up $this->nodeTranslationRepository->save($translation); in try-catch block
| return $store; | ||
| } | ||
|
|
||
| public function getIdByCode(string $storeCode): ?int |
There was a problem hiding this comment.
Is this function called somewhere? I don't see any usages.
| /** | ||
| * @inheritDoc | ||
| */ | ||
| public function getTranslationId(): ?int |
There was a problem hiding this comment.
I think a declaration of the function getTranslationId() is missing in the NodeTranslationInterface
| /** | ||
| * @inheritDoc | ||
| */ | ||
| public function setTranslationId(int $id): NodeTranslationInterface |
There was a problem hiding this comment.
Same here and for getCreatedAt(), setCreatedAt(), getUpdatedAt(), setUpdatedAt()
| public function getValue(): string | ||
| { | ||
| return (string)$this->getData('value'); | ||
| } | ||
|
|
||
| public function setValue(string $value): void | ||
| { | ||
| $this->setData('value', $value); | ||
| } |
There was a problem hiding this comment.
Are these functions called somewhere? I don't see any usages, but please double check.
| namespace Snowdog\Menu\Plugin\Model\Menu\Node; | ||
|
|
||
| use Snowdog\Menu\Api\NodeTranslationRepositoryInterface; | ||
| use Snowdog\Menu\Api\Data\NodeTranslationInterface; |
There was a problem hiding this comment.
The class Snowdog\Menu\Api\Data\NodeTranslationInterface is imported but never used
| @@ -1,5 +1,5 @@ | |||
| { | |||
| "name": "snowdog/module-menu", | |||
| "name": "magebitcom/snowdog-module-menu", | |||
There was a problem hiding this comment.
Please don't overwrite module name in Snowdog repository
|
closing as #398 fixes the issues listed here. |
Added an option with a dynamic row to translate menu items.
Also works in import/export
Also works with "Import from Categories"
code might be a little rough & need improvements, as this was done in a few hours.