Skip to content

Commit

Permalink
Merge pull request #2701 in SW/shopware from sw-10310/5.0/add-support…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
Marcel Schmäing committed Jul 2, 2015
2 parents 1c325b1 + 33a3676 commit ead27b2
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
1 change: 1 addition & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ In this document you will find a changelog of the important changes related to t
* Use `bin/console sw:snippets:validate <your-plugin-snippets-path>` to check the validity of your snippets.
* Defining a snippet value in multiple lines is deprecated.
* All snippet values that don't pass the validation should be refactored.
* The method `getSeoArticleQuery` in `sRewriteTable.php` was changed to select the translations for the article attributes.

## 5.0.1
* Create `sw:theme:dump:configuration` command to generate watch files for theme compiling
Expand Down
49 changes: 43 additions & 6 deletions engine/Shopware/Core/sRewriteTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,8 @@ public function sCreateRewriteTableArticles($lastUpdate, $limit = 1000)
)
);

$result = $this->mapArticleTranslationObjectData($result);

$result = Shopware()->Events()->filter(
'Shopware_Modules_RewriteTable_sCreateRewriteTableArticles_filterArticles',
$result,
Expand Down Expand Up @@ -947,9 +949,8 @@ public function sCreateRewriteTableArticles($lastUpdate, $limit = 1000)
public function getSeoArticleQuery()
{
return "
SELECT a.*, IF(atr.name IS NULL OR atr.name='', a.name, atr.name) as name,
d.ordernumber, d.suppliernumber, s.name as supplier, datum as date,
d.releasedate, changetime as changed, metaTitle, at.attr1, at.attr2,
SELECT a.*, d.ordernumber, d.suppliernumber, s.name as supplier, datum as date,
d.releasedate, changetime as changed, metaTitle, ct.objectdata, at.attr1, at.attr2,
at.attr3, at.attr4, at.attr5, at.attr6, at.attr7, at.attr8, at.attr9,
at.attr10,at.attr11, at.attr12, at.attr13, at.attr14, at.attr15, at.attr16,
at.attr17, at.attr18, at.attr19, at.attr20
Expand All @@ -968,9 +969,10 @@ public function getSeoArticleQuery()
LEFT JOIN s_articles_attributes at
ON at.articledetailsID=d.id
LEFT JOIN s_articles_translations atr
ON atr.articleID=a.id
AND atr.languageID=?
LEFT JOIN s_core_translations ct
ON ct.objectkey=a.id
AND ct.objectlanguage=?
AND ct.objecttype='article'
LEFT JOIN s_articles_supplier s
ON s.id=a.supplierID
Expand Down Expand Up @@ -1274,4 +1276,39 @@ private function insertStaticPageUrls($offset, $limit)
$this->sInsertUrl($org_path, $path);
}
}

/**
* Maps the translation of the objectdata from the s_core_translations in the article array
* @param array $articles
* @return mixed
*/
public function mapArticleTranslationObjectData($articles)
{
foreach ($articles as &$article) {
if (empty($article['objectdata'])) {
unset($article['objectdata']);
continue;
}

$data = unserialize($article['objectdata']);
if (!$data) {
continue;
}

$data['name'] = (!empty($data['txtArtikel'])) ? $data['txtArtikel'] : $article['name'];
$data['description_long'] = (!empty($data['txtlangbeschreibung'])) ? $data['txtlangbeschreibung'] : $article['description_long'];
$data['description'] = (!empty($data['txtshortdescription'])) ? $data['txtshortdescription'] : $article['description'];
$data['keywords'] = (!empty($data['txtkeywords'])) ? $data['txtkeywords'] : $article['keykwords'];

unset($article['objectdata']);
unset($data['txtArtikel']);
unset($data['txtlangbeschreibung']);
unset($data['txtlangbeschreibung']);
unset($data['txtkeywords']);

$article = array_merge($article, $data);
}

return $articles;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ protected function seoArticle($offset, $limit, $shop)
'1900-01-01'
));

$articles = $this->RewriteTable()->mapArticleTranslationObjectData($articles);

$articles = $this->get('events')->filter(
'Shopware_Controllers_Backend_Seo_seoArticle_filterArticles',
$articles,
Expand Down

0 comments on commit ead27b2

Please sign in to comment.