Skip to content

Commit ead27b2

Browse files
author
Marcel Schmäing
committed
Merge pull request #2701 in SW/shopware from sw-10310/5.0/add-support-for-s_core_translations_to-the-seo-url-generation to 5.0
* commit '33a3676c241815a6b7203da6b36e05f1933e45af': SW-10310 - added support for the s_core_translations to the SEO URL generation
2 parents 1c325b1 + 33a3676 commit ead27b2

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

UPGRADE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ In this document you will find a changelog of the important changes related to t
7474
* Use `bin/console sw:snippets:validate <your-plugin-snippets-path>` to check the validity of your snippets.
7575
* Defining a snippet value in multiple lines is deprecated.
7676
* All snippet values that don't pass the validation should be refactored.
77+
* The method `getSeoArticleQuery` in `sRewriteTable.php` was changed to select the translations for the article attributes.
7778

7879
## 5.0.1
7980
* Create `sw:theme:dump:configuration` command to generate watch files for theme compiling

engine/Shopware/Core/sRewriteTable.php

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,8 @@ public function sCreateRewriteTableArticles($lastUpdate, $limit = 1000)
906906
)
907907
);
908908

909+
$result = $this->mapArticleTranslationObjectData($result);
910+
909911
$result = Shopware()->Events()->filter(
910912
'Shopware_Modules_RewriteTable_sCreateRewriteTableArticles_filterArticles',
911913
$result,
@@ -947,9 +949,8 @@ public function sCreateRewriteTableArticles($lastUpdate, $limit = 1000)
947949
public function getSeoArticleQuery()
948950
{
949951
return "
950-
SELECT a.*, IF(atr.name IS NULL OR atr.name='', a.name, atr.name) as name,
951-
d.ordernumber, d.suppliernumber, s.name as supplier, datum as date,
952-
d.releasedate, changetime as changed, metaTitle, at.attr1, at.attr2,
952+
SELECT a.*, d.ordernumber, d.suppliernumber, s.name as supplier, datum as date,
953+
d.releasedate, changetime as changed, metaTitle, ct.objectdata, at.attr1, at.attr2,
953954
at.attr3, at.attr4, at.attr5, at.attr6, at.attr7, at.attr8, at.attr9,
954955
at.attr10,at.attr11, at.attr12, at.attr13, at.attr14, at.attr15, at.attr16,
955956
at.attr17, at.attr18, at.attr19, at.attr20
@@ -968,9 +969,10 @@ public function getSeoArticleQuery()
968969
LEFT JOIN s_articles_attributes at
969970
ON at.articledetailsID=d.id
970971
971-
LEFT JOIN s_articles_translations atr
972-
ON atr.articleID=a.id
973-
AND atr.languageID=?
972+
LEFT JOIN s_core_translations ct
973+
ON ct.objectkey=a.id
974+
AND ct.objectlanguage=?
975+
AND ct.objecttype='article'
974976
975977
LEFT JOIN s_articles_supplier s
976978
ON s.id=a.supplierID
@@ -1274,4 +1276,39 @@ private function insertStaticPageUrls($offset, $limit)
12741276
$this->sInsertUrl($org_path, $path);
12751277
}
12761278
}
1279+
1280+
/**
1281+
* Maps the translation of the objectdata from the s_core_translations in the article array
1282+
* @param array $articles
1283+
* @return mixed
1284+
*/
1285+
public function mapArticleTranslationObjectData($articles)
1286+
{
1287+
foreach ($articles as &$article) {
1288+
if (empty($article['objectdata'])) {
1289+
unset($article['objectdata']);
1290+
continue;
1291+
}
1292+
1293+
$data = unserialize($article['objectdata']);
1294+
if (!$data) {
1295+
continue;
1296+
}
1297+
1298+
$data['name'] = (!empty($data['txtArtikel'])) ? $data['txtArtikel'] : $article['name'];
1299+
$data['description_long'] = (!empty($data['txtlangbeschreibung'])) ? $data['txtlangbeschreibung'] : $article['description_long'];
1300+
$data['description'] = (!empty($data['txtshortdescription'])) ? $data['txtshortdescription'] : $article['description'];
1301+
$data['keywords'] = (!empty($data['txtkeywords'])) ? $data['txtkeywords'] : $article['keykwords'];
1302+
1303+
unset($article['objectdata']);
1304+
unset($data['txtArtikel']);
1305+
unset($data['txtlangbeschreibung']);
1306+
unset($data['txtlangbeschreibung']);
1307+
unset($data['txtkeywords']);
1308+
1309+
$article = array_merge($article, $data);
1310+
}
1311+
1312+
return $articles;
1313+
}
12771314
}

engine/Shopware/Plugins/Default/Core/RebuildIndex/Controllers/Seo.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ protected function seoArticle($offset, $limit, $shop)
213213
'1900-01-01'
214214
));
215215

216+
$articles = $this->RewriteTable()->mapArticleTranslationObjectData($articles);
217+
216218
$articles = $this->get('events')->filter(
217219
'Shopware_Controllers_Backend_Seo_seoArticle_filterArticles',
218220
$articles,

0 commit comments

Comments
 (0)