Skip to content

Commit

Permalink
Merge pull request #574 from magento-firedrakes/MAGETWO-52374
Browse files Browse the repository at this point in the history
[Firedrakes] Bugfixes
  • Loading branch information
Momotenko,Natalia(nmomotenko) committed May 5, 2016
2 parents 870bdfb + 0484c7a commit 135f967
Show file tree
Hide file tree
Showing 23 changed files with 985 additions and 136 deletions.
4 changes: 0 additions & 4 deletions app/code/Magento/Dhl/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
<label>Enabled for Checkout</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="active_rma" translate="label" type="select" sortOrder="15" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enabled for RMA</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="gateway_url" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Gateway URL</label>
</field>
Expand Down
1 change: 0 additions & 1 deletion app/code/Magento/Dhl/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ None,None
"Field ","Field "
" is required."," is required."
"Enabled for Checkout","Enabled for Checkout"
"Enabled for RMA","Enabled for RMA"
"Gateway URL","Gateway URL"
Title,Title
"Access ID","Access ID"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

use Magento\Downloadable\Api\Data\SampleInterfaceFactory as SampleFactory;
use Magento\Downloadable\Api\Data\LinkInterfaceFactory as LinkFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Json\Helper\Data as JsonHelper;

/**
* Class Downloadable
Expand All @@ -23,34 +23,30 @@ class Downloadable
/**
* @var SampleFactory
*/
protected $sampleFactory;
private $sampleFactory;

/**
* @var LinkFactory
*/
protected $linkFactory;
private $linkFactory;

/**
* @var JsonHelper
* @var \Magento\Downloadable\Model\Sample\Builder
*/
protected $jsonHelper;
private $sampleBuilder;

/**
* @var \Magento\Downloadable\Model\Link\Builder
*/
private $linkBuilder;

/**
* @param RequestInterface $request
* @param SampleFactory $sampleFactory
* @param LinkFactory $linkFactory
* @param JsonHelper $jsonHelper
*/
public function __construct(
RequestInterface $request,
SampleFactory $sampleFactory,
LinkFactory $linkFactory,
JsonHelper $jsonHelper
RequestInterface $request
) {
$this->request = $request;
$this->linkFactory = $linkFactory;
$this->sampleFactory = $sampleFactory;
$this->jsonHelper = $jsonHelper;
}

/**
Expand All @@ -74,49 +70,14 @@ public function afterInitialize(
if (isset($downloadable['link']) && is_array($downloadable['link'])) {
$links = [];
foreach ($downloadable['link'] as $linkData) {
if (!$linkData || (isset($linkData['is_delete']) && (bool)$linkData['is_delete'])) {
if (!$linkData || (isset($linkData['is_delete']) && $linkData['is_delete'])) {
continue;
} else {
// TODO: need to implement setLinkFileContent()
$link = $this->linkFactory->create(['data' => $linkData]);
if (isset($linkData['type'])) {
$link->setLinkType($linkData['type']);
}
if (isset($linkData['file'])) {
$link->setFile($this->jsonHelper->jsonEncode($linkData['file']));
}
if (isset($linkData['file_content'])) {
$link->setLinkFileContent($linkData['file_content']);
}
$link->setId(null);
if (isset($linkData['link_id'])) {
$link->setId($linkData['link_id']);
}
if (isset($linkData['sample']['type'])) {
$link->setSampleType($linkData['sample']['type']);
}
if (isset($linkData['sample']['file'])) {
$link->setSampleFileData($this->jsonHelper->jsonEncode($linkData['sample']['file']));
}
if (isset($linkData['sample']['url'])) {
$link->setSampleUrl($linkData['sample']['url']);
}
if (isset($linkData['sample']['file_content'])) {
$link->setSampleFileContent($linkData['file_content']);
}
$link->setStoreId($product->getStoreId());
$link->setWebsiteId($product->getStore()->getWebsiteId());
$link->setProductWebsiteIds($product->getWebsiteIds());
if (!$link->getSortOrder()) {
$link->setSortOrder(1);
}
if (null === $link->getPrice()) {
$link->setPrice(0);
}
if ($link->getIsUnlimited()) {
$link->setNumberOfDownloads(0);
}
$links[] = $link;
$links[] = $this->getLinkBuilder()->setData(
$linkData
)->build(
$this->getLinkFactory()->create()
);
}
}
$extension->setDownloadableProductLinks($links);
Expand All @@ -127,25 +88,11 @@ public function afterInitialize(
if (!$sampleData || (isset($sampleData['is_delete']) && (bool)$sampleData['is_delete'])) {
continue;
} else {
$sample = $this->sampleFactory->create(['data' => $sampleData]);
$sample->setId(null);
if (isset($sampleData['sample_id'])) {
$sample->setId($sampleData['sample_id']);
}
$sample->setStoreId($product->getStoreId());
if (isset($sampleData['type'])) {
$sample->setSampleType($sampleData['type']);
}
if (isset($sampleData['file'])) {
$sample->setFile($this->jsonHelper->jsonEncode($sampleData['file']));
}
if (isset($sampleData['sample_url'])) {
$sample->setSampleUrl($sampleData['sample_url']);
}
if (!$sample->getSortOrder()) {
$sample->setSortOrder(1);
}
$samples[] = $sample;
$samples[] = $this->getSampleBuilder()->setData(
$sampleData
)->build(
$this->getSampleFactory()->create()
);
}
}
$extension->setDownloadableProductSamples($samples);
Expand All @@ -159,4 +106,66 @@ public function afterInitialize(
}
return $product;
}

/**
* Get LinkBuilder instance
*
* @deprecated
* @return \Magento\Downloadable\Model\Link\Builder
*/
private function getLinkBuilder()
{
if (!$this->linkBuilder) {
$this->linkBuilder = ObjectManager::getInstance()->get(\Magento\Downloadable\Model\Link\Builder::class);
}

return $this->linkBuilder;
}

/**
* Get SampleBuilder instance
*
* @deprecated
* @return \Magento\Downloadable\Model\Sample\Builder
*/
private function getSampleBuilder()
{
if (!$this->sampleBuilder) {
$this->sampleBuilder = ObjectManager::getInstance()->get(
\Magento\Downloadable\Model\Sample\Builder::class
);
}

return $this->sampleBuilder;
}

/**
* Get LinkFactory instance
*
* @deprecated
* @return LinkFactory
*/
private function getLinkFactory()
{
if (!$this->linkFactory) {
$this->linkFactory = ObjectManager::getInstance()->get(LinkFactory::class);
}

return $this->linkFactory;
}

/**
* Get Sample Factory
*
* @deprecated
* @return SampleFactory
*/
private function getSampleFactory()
{
if (!$this->sampleFactory) {
$this->sampleFactory = ObjectManager::getInstance()->get(SampleFactory::class);
}

return $this->sampleFactory;
}
}
Loading

0 comments on commit 135f967

Please sign in to comment.