Skip to content

Commit

Permalink
Merge pull request #221 in PLUG_OPEN/backend_swagimportexport from bu…
Browse files Browse the repository at this point in the history
…gfix/pt-3999/fix-article-translation-export-query to master

* commit '13877c4b2e40662d0c748fccb47a8df4a623a7b3':
  PT-3999 - Fix article translation export query
  • Loading branch information
mitelg committed Nov 2, 2016
2 parents 0dff7fe + 13877c4 commit d9c398f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,8 @@ public function readRecordIds($start, $limit, $filter)

$builder->select('t.id')
->from(Translation::class, 't')
->leftJoin(Detail::class, 'ad', 'WITH', 'ad.id = t.key')
->where('t.type = :articleType')
->orWhere('t.type = :variantType AND ad.kind != :kind')
->setParameters(['articleType' => 'article', 'variantType' => 'variant', 'kind' => 1])
->where('t.type IN (:types)')
->setParameter('types', ['article', 'variant'])
;

if ($start) {
Expand Down Expand Up @@ -417,39 +415,24 @@ public function getTranslations($ids)
{
$translationIds = implode(',', $ids);

$translationColumns = 'variant.id as id, variant.ordernumber as articleNumber, variant.kind as kind,
ct.objectdata as variantData, ct2.objectdata as articleData, ct.objectlanguage as languageId';

$sql = "(SELECT $translationColumns
FROM `s_core_translations` AS ct
LEFT JOIN s_articles AS article
ON article.id = ct.objectkey
LEFT JOIN s_articles_details AS variant
ON variant.articleID = article.id
LEFT JOIN `s_core_translations` AS ct2
ON ct2.objectkey = variant.articleID AND ct2.objecttype = 'article' AND ct2.objectlanguage = ct.objectlanguage
WHERE ct.id IN ($translationIds) AND ct.objecttype = 'article'
GROUP BY article.id, languageId)
UNION
(SELECT $translationColumns
FROM `s_core_translations` AS ct
LEFT JOIN s_articles_details AS variant
ON variant.id = ct.objectkey
LEFT JOIN `s_core_translations` AS ct2
ON ct2.objectkey = variant.articleID AND ct2.objecttype = 'article' AND ct2.objectlanguage = ct.objectlanguage
WHERE ct.id IN ($translationIds) AND ct.objecttype = 'variant')
ORDER BY languageId ASC
";
$sql = "
(SELECT ad.id as id, ad.ordernumber as articleNumber, ad.kind as kind,
t.objectdata as articleData, t.objectdata as variantData, t.objectlanguage as languageId
FROM s_core_translations t
LEFT JOIN s_articles a ON (t.objectkey = a.id)
LEFT JOIN s_articles_details ad ON (ad.articleID = a.id AND ad.kind = 1)
WHERE t.id IN ($translationIds) AND t.objecttype = 'article')
UNION
(SELECT ad.id as id, ad.ordernumber as articleNumber, ad.kind as kind,
t.objectdata as articleData, t.objectdata as variantData, t.objectlanguage as languageId
FROM s_core_translations t
LEFT JOIN s_articles_details ad ON (t.objectkey = ad.id)
WHERE t.id IN ($translationIds) AND t.objecttype = 'variant')
ORDER BY languageId ASC
";

return $this->db->query($sql)->fetchAll();
}
Expand Down
6 changes: 3 additions & 3 deletions Tests/Helper/ExportFiles/export_articles_translations.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
articlenumber;languageId;name;description;longdescription;keywords;metatitle
SW10002.1;2;Munsterland Lagerkorn 32%;;<p>Ita si ardor laxe eu Cogo arx subaudio. Os, color attero, an. Hi inservio quatenus/quatinus, eu. Pax percunctor, ut. Me Mica. Ne, in plus neo pars ne navale quo Heniis varius, St. Iam vae ne inter Idem devenio parum accredo Neco nam byssus ales an Seu re is, mors vir incrementabiliter hio desisto Noxa chirographum eo, os, agon os nec lac enucleo his ile pes vos Suppellex, re. Vae libro corium Pul.</p>;;
SW10002.3;2;Munsterland Lagerkorn 32%;;<p>Ita si ardor laxe eu Cogo arx subaudio. Os, color attero, an. Hi inservio quatenus/quatinus, eu. Pax percunctor, ut. Me Mica. Ne, in plus neo pars ne navale quo Heniis varius, St. Iam vae ne inter Idem devenio parum accredo Neco nam byssus ales an Seu re is, mors vir incrementabiliter hio desisto Noxa chirographum eo, os, agon os nec lac enucleo his ile pes vos Suppellex, re. Vae libro corium Pul.</p>;;
SW10003;2;Munsterland Aperitif 16%;;<p>Io copia moeror immo pro audio modestia. Permaneo animosus etsi furax, aversor, faenum Pecus, mus me dux ferociter interpellatio certo. infrequentia Illis Quamquam Invidus, indutus voco tot Velociter, rare qui Limbus in Uter sub Ferito. Hinc lacrima Tutor gens Stabulaus antrum levis se voveo quemadmodum ruo illa sidereus. Luo Modicus tutela sedo Uxor contineo, ait ait crebra exsecror Ruga Sospes gratuita se Quae praevideo</p>;;
SW10005.1;2;Emmelkamp elder liqueur;;<p>Ita si ardor laxe eu Cogo arx subaudio. Os, color attero, an. Hi inservio quatenus/quatinus, eu. Pax percunctor, ut. Me Mica. Ne, in plus neo pars ne navale quo Heniis varius, St. Iam vae ne inter Idem devenio parum accredo Neco nam byssus ales an Seu re is, mors vir incrementabiliter hio desisto Noxa chirographum eo, os, agon os nec lac enucleo his ile pes vos Suppellex, re. Vae libro corium Pul.</p>;;
SW10007.1;2;Juniper premium extra mild 32%;;<p>Ita si ardor laxe eu Cogo arx subaudio. Os, color attero, an. Hi inservio quatenus/quatinus, eu. Pax percunctor, ut. Me Mica. Ne, in plus neo pars ne navale quo Heniis varius, St. Iam vae ne inter Idem devenio parum accredo Neco nam byssus ales an Seu re is, mors vir incrementabiliter hio desisto Noxa chirographum eo, os, agon os nec lac enucleo his ile pes vos Suppellex, re. Vae libro corium Pul.</p>;;
Expand Down Expand Up @@ -70,11 +70,11 @@ SW10198;2;Article in clearance sale;With the clearance sale function you can sal
SW10199;2;Article marking NEW;"Depending on the setting, newly created articles can carry the description ""NEW"".";"<p>Depending on the setting, newly created articles can carry the description ""NEW"".</p>";;
SW10200;2;Highlighted presentation;"This option allows you to mark articles in the storefront in a better way. As standard, these articles are created as ""Tip"".";"<p><span>This option allows you to mark articles in the storefront in a better way. As standard, these articles are created as ""Tip"".<br /></span></p>
<p><span>&nbsp;</span></p>";;
SW10201.1;2;Article with standard configurator;The standard configurator offers the opportunity, to selct the desired constellation, without following a certain order. All groups can be selected by customers with the corresponding options.;<p>The standard configurator offers the opportunity, to selct the desired constellation, without following a certain order. All groups can be selected by customers with the corresponding options.</p>;;
SW10201.2;2;Article with standard configurator;The standard configurator offers the opportunity, to selct the desired constellation, without following a certain order. All groups can be selected by customers with the corresponding options.;<p>The standard configurator offers the opportunity, to selct the desired constellation, without following a certain order. All groups can be selected by customers with the corresponding options.</p>;;
SW10202.1;2;Article with choice configurator;In contrast to the standard configurator, the order of the choice configurator has to be executed step by step.;<p>In contrast to the standard configurator, the order of the choice configurator has to be executed step by step. Having made the first selection, the second box will be activated. Only after filling out the last box, the shopping cart button becomes visible.</p>;;
SW10203.1;2;Article with table configurator;With this configurator variant, your customer gets displayed the selecting opportunities in a table. This way, he can see, which options he has and what they cost.;<p>With this configurator variant, your customer gets displayed the selecting opportunities in a table. This way, he can see, which options he has and what they cost.</p>;;
SW10204.1;2;Article with surcharge configurator;The connection between configurator and accessory function offers new opportunities;<p>The connection between configurator and accessory function offers new opportunities. Your customers can put together their own articles and add their creation to the shopping cart with a single mouseclick.</p>;;
SW10205.1;2;Article with basic price calculation;You can define the basic article price for every article and everey category.;<p>You can define the basic article price for every article and everey category.</p>;;
SW10205.3;2;Article with basic price calculation;You can define the basic article price for every article and everey category.;<p>You can define the basic article price for every article and everey category.</p>;;
SW10206;2;Graduated prices, min./max. purchase quantity;You can define min. and max purchase quantities already in the standard version of Shopware.;<p>You can define min. and max purchase quantities already in the standard version of Shopware.</p>;;
SW10207;2;Pseudo price;The pseudo price appears small and crossed out above the actual price of the article. You can easily manage this function in the backend while creating an article. ;"<p>The pseudo price appears small and crossed out above the actual price of the article. You can easily manage this function in the backend while creating an article.</p>
<p>&nbsp;</p>";;
Expand Down
20 changes: 10 additions & 10 deletions Tests/Helper/ExportFiles/export_articles_translations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</Header>
<Translations>
<Translation>
<articlenumber>SW10002.1</articlenumber>
<articlenumber>SW10002.3</articlenumber>
<languageId>2</languageId>
<name>Munsterland Lagerkorn 32%</name>
<description></description>
Expand Down Expand Up @@ -630,13 +630,13 @@
<languageId>2</languageId>
<name>Highlighted presentation</name>
<description>This option allows you to mark articles in the storefront in a better way. As standard, these articles are created as "Tip".</description>
<longdescription><![CDATA[<p><span>This option allows you to mark articles in the storefront in a better way. As standard, these articles are created as "Tip".<br /></span></p>
<longdescription><![CDATA[<p><span>This option allows you to mark articles in the storefront in a better way. As standard, these articles are created as "Tip".<br /></span></p>
<p><span>&nbsp;</span></p>]]></longdescription>
<keywords></keywords>
<metatitle></metatitle>
</Translation>
<Translation>
<articlenumber>SW10201.1</articlenumber>
<articlenumber>SW10201.2</articlenumber>
<languageId>2</languageId>
<name>Article with standard configurator</name>
<description>The standard configurator offers the opportunity, to selct the desired constellation, without following a certain order. All groups can be selected by customers with the corresponding options.</description>
Expand Down Expand Up @@ -672,7 +672,7 @@
<metatitle></metatitle>
</Translation>
<Translation>
<articlenumber>SW10205.1</articlenumber>
<articlenumber>SW10205.3</articlenumber>
<languageId>2</languageId>
<name>Article with basic price calculation</name>
<description>You can define the basic article price for every article and everey category.</description>
Expand All @@ -694,7 +694,7 @@
<languageId>2</languageId>
<name>Pseudo price</name>
<description>The pseudo price appears small and crossed out above the actual price of the article. You can easily manage this function in the backend while creating an article. </description>
<longdescription><![CDATA[<p>The pseudo price appears small and crossed out above the actual price of the article. You can easily manage this function in the backend while creating an article.</p>
<longdescription><![CDATA[<p>The pseudo price appears small and crossed out above the actual price of the article. You can easily manage this function in the backend while creating an article.</p>
<p>&nbsp;</p>]]></longdescription>
<keywords></keywords>
<metatitle></metatitle>
Expand Down Expand Up @@ -749,7 +749,7 @@
<languageId>2</languageId>
<name>Express shipping</name>
<description>In Shopware , you have the opportunity to ship an article via express. This way, of cource, the customer is charged a higher fee. </description>
<longdescription><![CDATA[<p>In Shopware , you have the opportunity to ship an article via express. This way, of cource, the customer is charged a higher fee.</p>
<longdescription><![CDATA[<p>In Shopware , you have the opportunity to ship an article via express. This way, of cource, the customer is charged a higher fee.</p>
<p>To do so, you can choose between "normal" and "express" during the checkout process.<br /><br /></p>]]></longdescription>
<keywords></keywords>
<metatitle></metatitle>
Expand All @@ -759,7 +759,7 @@
<languageId>2</languageId>
<name>Article free of shipping costs</name>
<description>You have the opportunity to ship an article free of shipping costs. All you have to do is selecting the field "free of shipping costs" in the article data overview. </description>
<longdescription><![CDATA[<p>You have the opportunity to ship an article free of shipping costs. All you have to do is selecting the field "free of shipping costs" in the article data overview.</p>
<longdescription><![CDATA[<p>You have the opportunity to ship an article free of shipping costs. All you have to do is selecting the field "free of shipping costs" in the article data overview.</p>
<p>Add this article to you shopping cart an watch the result.</p>]]></longdescription>
<keywords></keywords>
<metatitle></metatitle>
Expand All @@ -769,8 +769,8 @@
<languageId>2</languageId>
<name>Shipping costs options</name>
<description>Check out various configurations concerning the shipping costs setting.</description>
<longdescription><![CDATA[<p>Check out various configurations concerning the shipping costs setting.</p>
<p>Define standard shipping types, alternate shipping types, surcharge shipping types and more.</p>
<longdescription><![CDATA[<p>Check out various configurations concerning the shipping costs setting.</p>
<p>Define standard shipping types, alternate shipping types, surcharge shipping types and more.</p>
<p>You can also define shipping costs for weight, price, amot of articles and your own calculations.</p>]]></longdescription>
<keywords></keywords>
<metatitle></metatitle>
Expand Down Expand Up @@ -816,7 +816,7 @@
<languageId>2</languageId>
<name><![CDATA[Payment methods & risk management]]></name>
<description>In Shopware, you have different opportunities to handle the risk management</description>
<longdescription><![CDATA[<p>In Shopware, you have different opportunities to handle the risk management. You can use them or other factors to define certain payment methods for certain customer groups.</p>
<longdescription><![CDATA[<p>In Shopware, you have different opportunities to handle the risk management. You can use them or other factors to define certain payment methods for certain customer groups.</p>
<p>In this example, you are not offered the payment method "invoice" for instance".</p>]]></longdescription>
<keywords></keywords>
<metatitle></metatitle>
Expand Down

0 comments on commit d9c398f

Please sign in to comment.