Skip to content

Commit

Permalink
Merge pull request #113 from magento-api/merged-prs
Browse files Browse the repository at this point in the history
Combined PRs
  • Loading branch information
kandy authored Jun 15, 2016
2 parents e7ab10a + 86bca45 commit 5e16608
Show file tree
Hide file tree
Showing 48 changed files with 1,412 additions and 275 deletions.
5 changes: 4 additions & 1 deletion app/code/Magento/Backup/Model/Fs/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,10 @@ protected function _generateRow($filename)
$row[$key] = $value;
}
$row['size'] = $this->_varDirectory->stat($this->_varDirectory->getRelativePath($filename))['size'];
$row['id'] = $row['time'] . '_' . $row['type'];
if (isset($row['display_name']) && $row['display_name'] == '') {
$row['display_name'] = 'WebSetupWizard';
}
$row['id'] = $row['time'] . '_' . $row['type'] . (isset($row['display_name']) ? $row['display_name'] : '');
return $row;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
*/
protected $_indexValueAttributes = [
'status',
'gift_message_available',
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
protected $_indexValueAttributes = [
'status',
'tax_class_id',
'gift_message_available',
];

/**
Expand Down
16 changes: 14 additions & 2 deletions app/code/Magento/CatalogWidget/Block/Product/ProductsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

namespace Magento\CatalogWidget\Block\Product;

use Magento\Framework\DataObject\IdentityInterface;
use Magento\Widget\Block\BlockInterface;

/**
* Catalog Products List widget block
* Class ProductsList
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implements \Magento\Widget\Block\BlockInterface
class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implements BlockInterface, IdentityInterface
{
/**
* Default value for products count that will be shown
Expand Down Expand Up @@ -327,7 +330,16 @@ public function getPagerHtml()
*/
public function getIdentities()
{
return [\Magento\Catalog\Model\Product::CACHE_TAG];
$identities = [];
if ($this->getProductCollection()) {
foreach ($this->getProductCollection() as $product) {
if ($product instanceof IdentityInterface) {
$identities = array_merge($identities, $product->getIdentities());
}
}
}

return $identities ?: [\Magento\Catalog\Model\Product::CACHE_TAG];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,21 +261,10 @@ public function testCreateCollection($pagerEnable, $productsCount, $productsPerP
$this->collectionFactory->expects($this->once())->method('create')->willReturn($collection);
$this->productsList->setData('conditions_encoded', 'some_serialized_conditions');

$conditions = $this->getMockBuilder('\Magento\Rule\Model\Condition\Combine')
->setMethods(['collectValidatedAttributes'])
->disableOriginalConstructor()
->getMock();
$conditions->expects($this->once())->method('collectValidatedAttributes')
->with($collection)
->willReturnSelf();

$this->builder->expects($this->once())->method('attachConditionToCollection')
->with($collection, $conditions)
->with($collection, $this->getConditionsForCollection($collection))
->willReturnSelf();

$this->rule->expects($this->once())->method('loadPost')->willReturnSelf();
$this->rule->expects($this->once())->method('getConditions')->willReturn($conditions);

if ($productsPerPage) {
$this->productsList->setData('products_per_page', $productsPerPage);
} else {
Expand Down Expand Up @@ -333,7 +322,44 @@ public function testShowPager()

public function testGetIdentities()
{
$this->assertEquals([\Magento\Catalog\Model\Product::CACHE_TAG], $this->productsList->getIdentities());
$collection = $this->getMockBuilder('\Magento\Catalog\Model\ResourceModel\Product\Collection')
->setMethods([
'addAttributeToSelect',
'getIterator',
])->disableOriginalConstructor()
->getMock();

$product = $this->getMock('Magento\Framework\DataObject\IdentityInterface', ['getIdentities']);
$notProduct = $this->getMock('NotProduct', ['getIdentities']);
$product->expects($this->once())->method('getIdentities')->willReturn(['product_identity']);
$collection->expects($this->once())->method('getIterator')->willReturn(
new \ArrayIterator([$product, $notProduct])
);
$this->productsList->setData('product_collection', $collection);

$this->assertEquals(
['product_identity'],
$this->productsList->getIdentities()
);
}

/**
* @param $collection
* @return \PHPUnit_Framework_MockObject_MockObject
*/
private function getConditionsForCollection($collection)
{
$conditions = $this->getMockBuilder('\Magento\Rule\Model\Condition\Combine')
->setMethods(['collectValidatedAttributes'])
->disableOriginalConstructor()
->getMock();
$conditions->expects($this->once())->method('collectValidatedAttributes')
->with($collection)
->willReturnSelf();

$this->rule->expects($this->once())->method('loadPost')->willReturnSelf();
$this->rule->expects($this->once())->method('getConditions')->willReturn($conditions);
return $conditions;
}

public function testGetTitle()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\ConfigurableProduct\Block\Adminhtml\Order\Create;

use Magento\ConfigurableProduct\Model\Product\Type\Configurable;

class Sidebar
{
/**
* Get item qty
*
* @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject
* @param \Closure $proceed
* @param \Magento\Framework\DataObject $item
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGetItemQty(
\Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject,
\Closure $proceed,
\Magento\Framework\DataObject $item
) {
if ($item->getProduct()->getTypeId() == Configurable::TYPE_CODE) {
return '';
}
return $proceed($item);
}

/**
* Check whether product configuration is required before adding to order
*
* @param \Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject
* @param \Closure $proceed
* @param string $productType
* @return bool
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundIsConfigurationRequired(
\Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar $subject,
\Closure $proceed,
$productType
) {
if ($productType == Configurable::TYPE_CODE) {
return true;
}
return $proceed($productType);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class VariationHandler
/** @var \Magento\Catalog\Model\ProductFactory */
protected $productFactory;

/** @var \Magento\CatalogInventory\Api\StockConfigurationInterface */
/**
* @var \Magento\CatalogInventory\Api\StockConfigurationInterface
* @deprecated
*/
protected $stockConfiguration;

/**
Expand Down Expand Up @@ -168,14 +171,10 @@ protected function fillSimpleProductData(

$keysFilter = ['item_id', 'product_id', 'stock_id', 'type_id', 'website_id'];
$postData['stock_data'] = array_diff_key((array)$parentProduct->getStockData(), array_flip($keysFilter));
$postData['stock_data']['manage_stock'] = $postData['quantity_and_stock_status']['qty'] === '' ? 0 : 1;
if (!isset($postData['stock_data']['is_in_stock'])) {
$stockStatus = $parentProduct->getQuantityAndStockStatus();
$postData['stock_data']['is_in_stock'] = $stockStatus['is_in_stock'];
}
$configDefaultValue = $this->stockConfiguration->getManageStock($product->getStoreId());
$postData['stock_data']['use_config_manage_stock'] = $postData['stock_data']['manage_stock'] ==
$configDefaultValue ? 1 : 0;
$postData = $this->processMediaGallery($product, $postData);
$postData['status'] = isset($postData['status'])
? $postData['status']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,6 @@ public function testGenerateSimpleProducts()
$parentProductMock->expects($this->once())
->method('getQuantityAndStockStatus')
->willReturn(['is_in_stock' => 1]);
$newSimpleProductMock->expects($this->once())->method('getStoreId')->willReturn('store_id');
$this->stockConfiguration->expects($this->once())
->method('getManageStock')
->with('store_id')
->willReturn(1);
$newSimpleProductMock->expects($this->once())->method('addData')->willReturnSelf();
$parentProductMock->expects($this->once())->method('getWebsiteIds')->willReturn('website_id');
$newSimpleProductMock->expects($this->once())->method('setWebsiteIds')->with('website_id')->willReturnSelf();
Expand Down
3 changes: 3 additions & 0 deletions app/code/Magento/ConfigurableProduct/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<type name="Magento\Catalog\Model\Product\Validator">
<plugin name="configurable" type="Magento\ConfigurableProduct\Model\Product\Validator\Plugin" sortOrder="50" />
</type>
<type name="Magento\Sales\Block\Adminhtml\Order\Create\Sidebar\AbstractSidebar">
<plugin name="configurable" type="Magento\ConfigurableProduct\Block\Adminhtml\Order\Create\Sidebar" sortOrder="200"/>
</type>
<type name="Magento\ConfigurableProduct\Block\Adminhtml\Product\Attribute\Edit\Tab\Variations\Main">
<arguments>
<argument name="inputTypeFactory" xsi:type="object">Magento\Catalog\Model\System\Config\Source\InputtypeFactory</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ define([
options: options,
images: images,
sku: sku,
name: sku,
quantity: quantity,
price: price,
productId: productId,
Expand All @@ -91,6 +92,7 @@ define([
if (productId) {
variation.sku = product.sku;
variation.weight = product.weight;
variation.name = product.name;
gridExisting.push(this.prepareRowForGrid(variation));
} else {
gridNew.push(this.prepareRowForGrid(variation));
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/GiftMessage/Setup/InstallData.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
'label' => 'Allow Gift Message',
'input' => 'select',
'class' => '',
'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
'source' => 'Magento\Catalog\Model\Product\Attribute\Source\Boolean',
'global' => true,
'visible' => true,
'required' => false,
Expand Down
23 changes: 17 additions & 6 deletions app/code/Magento/GiftMessage/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,20 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
{
$setup->startSetup();

/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
$entityTypeId = $categorySetup->getEntityTypeId(Product::ENTITY);
$attributeSetId = $categorySetup->getAttributeSetId($entityTypeId, 'Default');
$attribute = $categorySetup->getAttribute($entityTypeId, 'gift_message_available');

if (version_compare($context->getVersion(), '2.0.1', '<')) {
/** @var \Magento\Catalog\Setup\CategorySetup $categorySetup */
$categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);

$groupName = 'Gift Options';

if (!$categorySetup->getAttributeGroup(Product::ENTITY, 'Default', $groupName)) {
$categorySetup->addAttributeGroup(Product::ENTITY, 'Default', $groupName, 60);
}

$entityTypeId = $categorySetup->getEntityTypeId(Product::ENTITY);
$attributeSetId = $categorySetup->getAttributeSetId($entityTypeId, 'Default');
$attribute = $categorySetup->getAttribute($entityTypeId, 'gift_message_available');

$categorySetup->addAttributeToGroup(
$entityTypeId,
$attributeSetId,
Expand All @@ -57,6 +58,16 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
);
}

if (version_compare($context->getVersion(), '2.1.0', '<')) {

$categorySetup->updateAttribute(
$entityTypeId,
$attribute['attribute_id'],
'source_model',
'Magento\Catalog\Model\Product\Attribute\Source\Boolean'
);
}

$setup->endSetup();
}
}
1 change: 0 additions & 1 deletion app/code/Magento/GiftMessage/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"magento/module-sales": "100.1.*",
"magento/module-backend": "100.1.*",
"magento/module-customer": "100.1.*",
"magento/module-eav": "100.1.*",
"magento/module-quote": "100.1.*",
"magento/framework": "100.1.*",
"magento/module-ui": "100.1.*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public function getAssociatedProducts($product)
$collection = $this->getAssociatedProductCollection(
$product
)->addAttributeToSelect(
['name', 'price']
['name', 'price', 'special_price', 'special_from_date', 'special_to_date']
)->addFilterByRequiredOptions()->setPositionOrder()->addStoreFilter(
$this->getStoreFilter($product)
)->addAttributeToFilter(
Expand Down
Loading

0 comments on commit 5e16608

Please sign in to comment.