Skip to content

Commit 135f967

Browse files
author
Momotenko,Natalia(nmomotenko)
committed
Merge pull request #574 from magento-firedrakes/MAGETWO-52374
[Firedrakes] Bugfixes
2 parents 870bdfb + 0484c7a commit 135f967

File tree

23 files changed

+985
-136
lines changed

23 files changed

+985
-136
lines changed

app/code/Magento/Dhl/etc/adminhtml/system.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
<label>Enabled for Checkout</label>
1515
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
1616
</field>
17-
<field id="active_rma" translate="label" type="select" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="0">
18-
<label>Enabled for RMA</label>
19-
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
20-
</field>
2117
<field id="gateway_url" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
2218
<label>Gateway URL</label>
2319
</field>

app/code/Magento/Dhl/i18n/en_US.csv

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ None,None
5757
"Field ","Field "
5858
" is required."," is required."
5959
"Enabled for Checkout","Enabled for Checkout"
60-
"Enabled for RMA","Enabled for RMA"
6160
"Gateway URL","Gateway URL"
6261
Title,Title
6362
"Access ID","Access ID"

app/code/Magento/Downloadable/Controller/Adminhtml/Product/Initialization/Helper/Plugin/Downloadable.php

Lines changed: 84 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
use Magento\Downloadable\Api\Data\SampleInterfaceFactory as SampleFactory;
99
use Magento\Downloadable\Api\Data\LinkInterfaceFactory as LinkFactory;
10+
use Magento\Framework\App\ObjectManager;
1011
use Magento\Framework\App\RequestInterface;
11-
use Magento\Framework\Json\Helper\Data as JsonHelper;
1212

1313
/**
1414
* Class Downloadable
@@ -23,34 +23,30 @@ class Downloadable
2323
/**
2424
* @var SampleFactory
2525
*/
26-
protected $sampleFactory;
26+
private $sampleFactory;
2727

2828
/**
2929
* @var LinkFactory
3030
*/
31-
protected $linkFactory;
31+
private $linkFactory;
3232

3333
/**
34-
* @var JsonHelper
34+
* @var \Magento\Downloadable\Model\Sample\Builder
3535
*/
36-
protected $jsonHelper;
36+
private $sampleBuilder;
37+
38+
/**
39+
* @var \Magento\Downloadable\Model\Link\Builder
40+
*/
41+
private $linkBuilder;
3742

3843
/**
3944
* @param RequestInterface $request
40-
* @param SampleFactory $sampleFactory
41-
* @param LinkFactory $linkFactory
42-
* @param JsonHelper $jsonHelper
4345
*/
4446
public function __construct(
45-
RequestInterface $request,
46-
SampleFactory $sampleFactory,
47-
LinkFactory $linkFactory,
48-
JsonHelper $jsonHelper
47+
RequestInterface $request
4948
) {
5049
$this->request = $request;
51-
$this->linkFactory = $linkFactory;
52-
$this->sampleFactory = $sampleFactory;
53-
$this->jsonHelper = $jsonHelper;
5450
}
5551

5652
/**
@@ -74,49 +70,14 @@ public function afterInitialize(
7470
if (isset($downloadable['link']) && is_array($downloadable['link'])) {
7571
$links = [];
7672
foreach ($downloadable['link'] as $linkData) {
77-
if (!$linkData || (isset($linkData['is_delete']) && (bool)$linkData['is_delete'])) {
73+
if (!$linkData || (isset($linkData['is_delete']) && $linkData['is_delete'])) {
7874
continue;
7975
} else {
80-
// TODO: need to implement setLinkFileContent()
81-
$link = $this->linkFactory->create(['data' => $linkData]);
82-
if (isset($linkData['type'])) {
83-
$link->setLinkType($linkData['type']);
84-
}
85-
if (isset($linkData['file'])) {
86-
$link->setFile($this->jsonHelper->jsonEncode($linkData['file']));
87-
}
88-
if (isset($linkData['file_content'])) {
89-
$link->setLinkFileContent($linkData['file_content']);
90-
}
91-
$link->setId(null);
92-
if (isset($linkData['link_id'])) {
93-
$link->setId($linkData['link_id']);
94-
}
95-
if (isset($linkData['sample']['type'])) {
96-
$link->setSampleType($linkData['sample']['type']);
97-
}
98-
if (isset($linkData['sample']['file'])) {
99-
$link->setSampleFileData($this->jsonHelper->jsonEncode($linkData['sample']['file']));
100-
}
101-
if (isset($linkData['sample']['url'])) {
102-
$link->setSampleUrl($linkData['sample']['url']);
103-
}
104-
if (isset($linkData['sample']['file_content'])) {
105-
$link->setSampleFileContent($linkData['file_content']);
106-
}
107-
$link->setStoreId($product->getStoreId());
108-
$link->setWebsiteId($product->getStore()->getWebsiteId());
109-
$link->setProductWebsiteIds($product->getWebsiteIds());
110-
if (!$link->getSortOrder()) {
111-
$link->setSortOrder(1);
112-
}
113-
if (null === $link->getPrice()) {
114-
$link->setPrice(0);
115-
}
116-
if ($link->getIsUnlimited()) {
117-
$link->setNumberOfDownloads(0);
118-
}
119-
$links[] = $link;
76+
$links[] = $this->getLinkBuilder()->setData(
77+
$linkData
78+
)->build(
79+
$this->getLinkFactory()->create()
80+
);
12081
}
12182
}
12283
$extension->setDownloadableProductLinks($links);
@@ -127,25 +88,11 @@ public function afterInitialize(
12788
if (!$sampleData || (isset($sampleData['is_delete']) && (bool)$sampleData['is_delete'])) {
12889
continue;
12990
} else {
130-
$sample = $this->sampleFactory->create(['data' => $sampleData]);
131-
$sample->setId(null);
132-
if (isset($sampleData['sample_id'])) {
133-
$sample->setId($sampleData['sample_id']);
134-
}
135-
$sample->setStoreId($product->getStoreId());
136-
if (isset($sampleData['type'])) {
137-
$sample->setSampleType($sampleData['type']);
138-
}
139-
if (isset($sampleData['file'])) {
140-
$sample->setFile($this->jsonHelper->jsonEncode($sampleData['file']));
141-
}
142-
if (isset($sampleData['sample_url'])) {
143-
$sample->setSampleUrl($sampleData['sample_url']);
144-
}
145-
if (!$sample->getSortOrder()) {
146-
$sample->setSortOrder(1);
147-
}
148-
$samples[] = $sample;
91+
$samples[] = $this->getSampleBuilder()->setData(
92+
$sampleData
93+
)->build(
94+
$this->getSampleFactory()->create()
95+
);
14996
}
15097
}
15198
$extension->setDownloadableProductSamples($samples);
@@ -159,4 +106,66 @@ public function afterInitialize(
159106
}
160107
return $product;
161108
}
109+
110+
/**
111+
* Get LinkBuilder instance
112+
*
113+
* @deprecated
114+
* @return \Magento\Downloadable\Model\Link\Builder
115+
*/
116+
private function getLinkBuilder()
117+
{
118+
if (!$this->linkBuilder) {
119+
$this->linkBuilder = ObjectManager::getInstance()->get(\Magento\Downloadable\Model\Link\Builder::class);
120+
}
121+
122+
return $this->linkBuilder;
123+
}
124+
125+
/**
126+
* Get SampleBuilder instance
127+
*
128+
* @deprecated
129+
* @return \Magento\Downloadable\Model\Sample\Builder
130+
*/
131+
private function getSampleBuilder()
132+
{
133+
if (!$this->sampleBuilder) {
134+
$this->sampleBuilder = ObjectManager::getInstance()->get(
135+
\Magento\Downloadable\Model\Sample\Builder::class
136+
);
137+
}
138+
139+
return $this->sampleBuilder;
140+
}
141+
142+
/**
143+
* Get LinkFactory instance
144+
*
145+
* @deprecated
146+
* @return LinkFactory
147+
*/
148+
private function getLinkFactory()
149+
{
150+
if (!$this->linkFactory) {
151+
$this->linkFactory = ObjectManager::getInstance()->get(LinkFactory::class);
152+
}
153+
154+
return $this->linkFactory;
155+
}
156+
157+
/**
158+
* Get Sample Factory
159+
*
160+
* @deprecated
161+
* @return SampleFactory
162+
*/
163+
private function getSampleFactory()
164+
{
165+
if (!$this->sampleFactory) {
166+
$this->sampleFactory = ObjectManager::getInstance()->get(SampleFactory::class);
167+
}
168+
169+
return $this->sampleFactory;
170+
}
162171
}

0 commit comments

Comments
 (0)