Skip to content

Commit

Permalink
Merge pull request #455 from magento-tango/MAGETWO-50596
Browse files Browse the repository at this point in the history
[Tango] Bug fixes
  • Loading branch information
Ganin, Roman(rganin) committed Mar 19, 2016
2 parents 255ceb2 + 041b746 commit be02d0d
Show file tree
Hide file tree
Showing 39 changed files with 1,216 additions and 759 deletions.

This file was deleted.

149 changes: 119 additions & 30 deletions app/code/Magento/Bundle/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
*/
namespace Magento\Bundle\Setup;

use Magento\Catalog\Model\Product;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Eav\Setup\EavSetup;

class UpgradeData implements UpgradeDataInterface
{
Expand Down Expand Up @@ -39,37 +40,125 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
/** @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'
);
$eavSetup->addAttributeGroup(ProductAttributeInterface::ENTITY_TYPE_CODE, 'Default', 'Bundle Items', 16);

$this->upgradePriceType($eavSetup);
$this->upgradeSkuType($eavSetup);
$this->upgradeWeightType($eavSetup);
$this->upgradeShipmentType($eavSetup);
}

$setup->endSetup();
}

/**
* Upgrade Dynamic Price attribute
*
* @param EavSetup $eavSetup
* @return void
*/
private function upgradePriceType(EavSetup $eavSetup)
{
$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'price_type',
'frontend_input',
'boolean',
31
);
$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'price_type',
'frontend_label',
'Dynamic Price'
);
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'price_type', 'default_value', 0);
}

/**
* Upgrade Dynamic Sku attribute
*
* @param EavSetup $eavSetup
* @return void
*/
private function upgradeSkuType(EavSetup $eavSetup)
{
$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'sku_type',
'frontend_input',
'boolean',
21
);
$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'sku_type',
'frontend_label',
'Dynamic SKU'
);
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'sku_type', 'default_value', 0);
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'sku_type', 'is_visible', 1);
}

/**
* Upgrade Dynamic Weight attribute
*
* @param EavSetup $eavSetup
* @return void
*/
private function upgradeWeightType(EavSetup $eavSetup)
{
$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'weight_type',
'frontend_input',
'boolean',
71
);
$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'weight_type',
'frontend_label',
'Dynamic Weight'
);
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'weight_type', 'default_value', 0);
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'weight_type', 'is_visible', 1);
}

/**
* Upgrade Ship Bundle Items attribute
*
* @param EavSetup $eavSetup
* @return void
*/
private function upgradeShipmentType(EavSetup $eavSetup)
{
$eavSetup->addAttributeToGroup(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'Default',
'Bundle Items',
'shipment_type',
1
);
$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'shipment_type',
'frontend_input',
'select'
);
$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'shipment_type',
'frontend_label',
'Ship Bundle Items'
);
$eavSetup->updateAttribute(
ProductAttributeInterface::ENTITY_TYPE_CODE,
'shipment_type',
'source_model',
'Magento\Bundle\Model\Product\Attribute\Source\Shipment\Type'
);
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'shipment_type', 'default_value', 0);
$eavSetup->updateAttribute(ProductAttributeInterface::ENTITY_TYPE_CODE, 'shipment_type', 'is_visible', 1);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,71 @@
namespace Magento\Bundle\Test\Unit\Ui\DataProvider\Product\Form\Modifier;

use Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\BundleSku;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Framework\Stdlib\ArrayManager;

/**
* Class BundleSkuTest
*/
class BundleSkuTest extends AbstractModifierTest
{
/**
* @return BundleSku
*/
protected function createModel()
{
return $this->objectManager->getObject(BundleSku::class, [
'arrayManager' => $this->arrayManagerMock,
]);
return $this->objectManager->getObject(
BundleSku::class,
['arrayManager' => $this->arrayManagerMock]
);
}

/**
* @return void
*/
public function testModifyMeta()
{
$skuTypePath = 'bundle-items/children/' . BundleSku::CODE_SKU_TYPE;
$skuTypeConfigPath = $skuTypePath . BundleSku::META_CONFIG_PATH;
$sourceMeta = [
'testGroup' => [
'bundle-items' => [
'children' => [
ProductAttributeInterface::CODE_SKU => [
'componentType' => 'testComponent',
],
BundleSku::CODE_SKU_TYPE => []
]
]
];
$skuTypeParams = [
'valueMap' => [
'false' => '1',
'true' => '0'
],
'validation' => [
'required-entry' => false
]
];
$modifiedMeta = $this->getModel()->modifyMeta($sourceMeta);
$this->assertArrayHasKey(BundleSku::CODE_SKU_TYPE, $modifiedMeta['testGroup']['children']);
$skuTypeMeta = [
'bundle-items' => [
'children' => [
BundleSku::CODE_SKU_TYPE => $skuTypeParams
]
]
];

$this->arrayManagerMock->expects(static::any())
->method('findPath')
->willReturnMap(
[
[
BundleSku::CODE_SKU_TYPE,
$sourceMeta,
null,
'children',
ArrayManager::DEFAULT_PATH_DELIMITER,
$skuTypePath
]
]
);
$this->arrayManagerMock->expects($this->once())
->method('merge')
->with($skuTypeConfigPath, $sourceMeta, $skuTypeParams)
->willReturn($skuTypeMeta);

$this->assertSame($skuTypeMeta, $this->getModel()->modifyMeta($sourceMeta));
}

/**
* @return void
*/
public function testModifyData()
{
$expectedData = [];
Expand Down
Loading

0 comments on commit be02d0d

Please sign in to comment.