Skip to content

Translations for the menu#360

Closed
EmilsM wants to merge 6 commits into
SnowdogApps:developfrom
magebitcom:feature/translations
Closed

Translations for the menu#360
EmilsM wants to merge 6 commits into
SnowdogApps:developfrom
magebitcom:feature/translations

Conversation

@EmilsM
Copy link
Copy Markdown

@EmilsM EmilsM commented Feb 26, 2025

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.

Comment on lines +194 to +216

// 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())
];
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like duplicate piece of code. I think you can use the function getStoreViews().

->setStoreId($storeId)
->setTitle($title);

$this->nodeTranslationRepository->save($translation);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's worth to wrap up $this->nodeTranslationRepository->save($translation); in try-catch block

return $store;
}

public function getIdByCode(string $storeCode): ?int
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this function called somewhere? I don't see any usages.

Comment thread Model/NodeTranslation.php
/**
* @inheritDoc
*/
public function getTranslationId(): ?int
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a declaration of the function getTranslationId() is missing in the NodeTranslationInterface

Comment thread Model/NodeTranslation.php
/**
* @inheritDoc
*/
public function setTranslationId(int $id): NodeTranslationInterface
Copy link
Copy Markdown
Contributor

@maartynaa maartynaa May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here and for getCreatedAt(), setCreatedAt(), getUpdatedAt(), setUpdatedAt()

Comment thread Model/NodeTranslation.php
Comment on lines +118 to +126
public function getValue(): string
{
return (string)$this->getData('value');
}

public function setValue(string $value): void
{
$this->setData('value', $value);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class Snowdog\Menu\Api\Data\NodeTranslationInterface is imported but never used

Comment thread composer.json
@@ -1,5 +1,5 @@
{
"name": "snowdog/module-menu",
"name": "magebitcom/snowdog-module-menu",
Copy link
Copy Markdown
Contributor

@maartynaa maartynaa May 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't overwrite module name in Snowdog repository

Aquive added a commit to Aquive/snowdog-magento2-menu that referenced this pull request Mar 12, 2026
@EmilsM
Copy link
Copy Markdown
Author

EmilsM commented Mar 13, 2026

closing as #398 fixes the issues listed here.

@EmilsM EmilsM closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants