-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-48913: Create and process PR
- Loading branch information
1 parent
b1b05c8
commit 566be67
Showing
517 changed files
with
34,772 additions
and
5,196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/code/Magento/Bundle/Model/Product/Attribute/Source/Price/Type.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Bundle\Model\Product\Attribute\Source\Price; | ||
|
||
/** | ||
* Bundle Price Type Attribute Renderer | ||
*/ | ||
class Type extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource | ||
{ | ||
/** | ||
* Get all options | ||
* | ||
* @return array | ||
*/ | ||
public function getAllOptions() | ||
{ | ||
if (null === $this->_options) { | ||
$this->_options = [ | ||
['label' => __('Dynamic'), 'value' => 0], | ||
['label' => __('Fixed'), 'value' => 1], | ||
]; | ||
} | ||
return $this->_options; | ||
} | ||
|
||
/** | ||
* Get a text for option value | ||
* | ||
* @param string|integer $value | ||
* @return string|bool | ||
*/ | ||
public function getOptionText($value) | ||
{ | ||
foreach ($this->getAllOptions() as $option) { | ||
if ($option['value'] == $value) { | ||
return $option['label']; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/code/Magento/Bundle/Model/Product/Attribute/Source/Shipment/Type.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Bundle\Model\Product\Attribute\Source\Shipment; | ||
|
||
/** | ||
* Bundle Shipment Type Attribute Renderer | ||
*/ | ||
class Type extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getAllOptions() | ||
{ | ||
if (null === $this->_options) { | ||
$this->_options = [ | ||
['label' => __('Together'), 'value' => 0], | ||
['label' => __('Separately'), 'value' => 1], | ||
]; | ||
} | ||
return $this->_options; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getOptionText($value) | ||
{ | ||
foreach ($this->getAllOptions() as $option) { | ||
if ($option['value'] == $value) { | ||
return $option['label']; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Bundle\Setup; | ||
|
||
use Magento\Catalog\Model\Product; | ||
use Magento\Framework\Setup\ModuleContextInterface; | ||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
use Magento\Framework\Setup\UpgradeDataInterface; | ||
use Magento\Eav\Setup\EavSetupFactory; | ||
|
||
class UpgradeData implements UpgradeDataInterface | ||
{ | ||
/** | ||
* @var EavSetupFactory | ||
*/ | ||
protected $eavSetupFactory; | ||
|
||
/** | ||
* UpgradeData constructor | ||
* | ||
* @param EavSetupFactory $eavSetupFactory | ||
*/ | ||
public function __construct(EavSetupFactory $eavSetupFactory) | ||
{ | ||
$this->eavSetupFactory = $eavSetupFactory; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context) | ||
{ | ||
$setup->startSetup(); | ||
|
||
if (version_compare($context->getVersion(), '2.0.2', '<')) { | ||
/** @var \Magento\Eav\Setup\EavSetup $eavSetup */ | ||
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); | ||
|
||
$eavSetup->updateAttribute(Product::ENTITY, 'price_type', 'frontend_input', 'boolean'); | ||
$eavSetup->updateAttribute( | ||
Product::ENTITY, | ||
'price_type', | ||
'source_model', | ||
'Magento\Bundle\Model\Product\Attribute\Source\Price\Type' | ||
); | ||
$eavSetup->updateAttribute(Product::ENTITY, 'sku_type', 'frontend_input', 'boolean'); | ||
$eavSetup->updateAttribute( | ||
Product::ENTITY, | ||
'sku_type', | ||
'source_model', | ||
'Magento\Bundle\Model\Product\Attribute\Source\Price\Type' | ||
); | ||
$eavSetup->updateAttribute(Product::ENTITY, 'weight_type', 'frontend_input', 'boolean'); | ||
$eavSetup->updateAttribute( | ||
Product::ENTITY, | ||
'weight_type', | ||
'source_model', | ||
'Magento\Bundle\Model\Product\Attribute\Source\Price\Type' | ||
); | ||
$eavSetup->updateAttribute(Product::ENTITY, 'shipment_type', 'frontend_input', 'select'); | ||
$eavSetup->updateAttribute(Product::ENTITY, 'shipment_type', 'frontend_label', __('Ship Bundle Items'), 1); | ||
$eavSetup->updateAttribute( | ||
Product::ENTITY, | ||
'shipment_type', | ||
'source_model', | ||
'Magento\Bundle\Model\Product\Attribute\Source\Shipment\Type' | ||
); | ||
} | ||
|
||
$setup->endSetup(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
app/code/Magento/Bundle/Test/Unit/Model/Product/Attribute/Source/Price/TypeTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Magento\Bundle\Test\Unit\Model\Product\Attribute\Source\Price; | ||
|
||
use Magento\Bundle\Model\Product\Attribute\Source\Price\Type; | ||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; | ||
|
||
/** | ||
* Class TypeTest | ||
*/ | ||
class TypeTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var Type | ||
*/ | ||
protected $model; | ||
|
||
/** | ||
* @var ObjectManager | ||
*/ | ||
protected $objectManager; | ||
|
||
protected function setUp() | ||
{ | ||
$this->objectManager = new ObjectManager($this); | ||
$this->model = $this->objectManager->getObject(Type::class); | ||
} | ||
|
||
public function testGetAllOptions() | ||
{ | ||
$this->assertEquals( | ||
[ | ||
['label' => __('Dynamic'), 'value' => 0], | ||
['label' => __('Fixed'), 'value' => 1], | ||
], | ||
$this->model->getAllOptions() | ||
); | ||
} | ||
|
||
public function testGetOptionText() | ||
{ | ||
$this->assertEquals(__('Dynamic'), $this->model->getOptionText(0)); | ||
} | ||
|
||
public function testGetOptionTextToBeFalse() | ||
{ | ||
$this->assertFalse($this->model->getOptionText(2)); | ||
} | ||
} |
Oops, something went wrong.