From 7aaac978646ae71a42ce7829c69d08b41b6c6a9c Mon Sep 17 00:00:00 2001
From: ah-net <103565001+ah-net@users.noreply.github.com>
Date: Wed, 8 Oct 2025 15:48:28 +0200
Subject: [PATCH] Save name on store level
---
src/Model/LandingPage.php | 6 +++++-
src/Model/ResourceModel/Page.php | 3 ++-
src/etc/db_schema.xml | 1 +
.../ui_component/emico_attributelanding_page_form.xml | 4 ++++
4 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/Model/LandingPage.php b/src/Model/LandingPage.php
index 4989832..91d221c 100644
--- a/src/Model/LandingPage.php
+++ b/src/Model/LandingPage.php
@@ -596,7 +596,6 @@ public function getLandingPageDataWithoutStore(): array
{
$fields = [
LandingPageInterface::PAGE_ID,
- LandingPageInterface::NAME,
LandingPageInterface::CREATED_AT,
LandingPageInterface::UPDATED_AT,
LandingPageInterface::OVERVIEW_PAGE_ID,
@@ -605,6 +604,10 @@ public function getLandingPageDataWithoutStore(): array
LandingPageInterface::STORE_ID,
];
+ if ($this->getData(LandingPageInterface::STORE_ID) === 0) {
+ $fields[] = LandingPageInterface::NAME;
+ }
+
return array_combine(
$fields,
array_map(fn($field) => $this->getData($field), $fields)
@@ -619,6 +622,7 @@ public function getLandingPageDataForStore(): array
$fields = [
LandingPageInterface::ACTIVE,
LandingPageInterface::STORE_ID,
+ LandingPageInterface::NAME,
LandingPageInterface::URL_PATH,
LandingPageInterface::CATEGORY_ID,
LandingPageInterface::HEADING,
diff --git a/src/Model/ResourceModel/Page.php b/src/Model/ResourceModel/Page.php
index a876c5f..16edc4d 100644
--- a/src/Model/ResourceModel/Page.php
+++ b/src/Model/ResourceModel/Page.php
@@ -11,6 +11,7 @@
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use Magento\Framework\Model\ResourceModel\Db\Context;
use Magento\Framework\Event\ManagerInterface as EventManager;
+use Zend_Db_Expr;
class Page extends AbstractDb
{
@@ -51,7 +52,7 @@ public function getLandingPageStoreData(int $landingPageId, int $storeId = 0): a
->join(
['p' => $this->getTable('emico_attributelanding_page')],
'ps.page_id = p.page_id',
- ['name']
+ ['name' => new Zend_Db_Expr('COALESCE(ps.name, p.name)')]
)
->where('ps.page_id = ?', $landingPageId)
->where('store_id = ?', $storeId);
diff --git a/src/etc/db_schema.xml b/src/etc/db_schema.xml
index b4342b7..92ad0f8 100644
--- a/src/etc/db_schema.xml
+++ b/src/etc/db_schema.xml
@@ -20,6 +20,7 @@
+
diff --git a/src/view/adminhtml/ui_component/emico_attributelanding_page_form.xml b/src/view/adminhtml/ui_component/emico_attributelanding_page_form.xml
index 01cab7c..4ce7404 100644
--- a/src/view/adminhtml/ui_component/emico_attributelanding_page_form.xml
+++ b/src/view/adminhtml/ui_component/emico_attributelanding_page_form.xml
@@ -97,6 +97,10 @@
-
- Page
+ - [STORE VIEW]
+ - 1
+ - 0
+ - 1