Skip to content

Commit

Permalink
Merge remote-tracking branch 'frontend/develop' into MAGETWO-58802
Browse files Browse the repository at this point in the history
  • Loading branch information
guz-anton committed Sep 23, 2016
2 parents 7003b2f + a3adb88 commit b2fcaba
Show file tree
Hide file tree
Showing 88 changed files with 1,068 additions and 109 deletions.
16 changes: 16 additions & 0 deletions app/code/Magento/Backend/Block/Widget/Form/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ class Container extends \Magento\Backend\Block\Widget\Container
* @var string
*/
protected $_blockGroup = 'Magento_Backend';

/**
* @var string
*/
const PARAM_BLOCK_GROUP = 'block_group';

/**
* @var string
*/
const PARAM_MODE = 'mode';

/**
* @var string
Expand All @@ -49,6 +59,12 @@ class Container extends \Magento\Backend\Block\Widget\Container
protected function _construct()
{
parent::_construct();
if ($this->hasData(self::PARAM_BLOCK_GROUP)) {
$this->_blockGroup = $this->_getData(self::PARAM_BLOCK_GROUP);
}
if ($this->hasData(self::PARAM_MODE)) {
$this->_mode = $this->_getData(self::PARAM_MODE);
}

$this->addButton(
'back',
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ public function getIdentities()
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
}
}

if (($this->getOrigData('status') != $this->getData('status')) || $this->isStockStatusChanged()) {
foreach ($this->getCategoryIds() as $categoryId) {
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
Expand All @@ -2289,7 +2289,7 @@ public function getIdentities()

/**
* Check whether stock status changed
*
*
* @return bool
*/
private function isStockStatusChanged()
Expand All @@ -2307,7 +2307,7 @@ private function isStockStatusChanged()
&& ($stockItem->getIsInStock() != $stockData['is_in_stock'])
);
}

/**
* Reload PriceInfo object
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ public function export()
while (true) {
++$page;
$entityCollection = $this->_getEntityCollection(true);
$entityCollection->setOrder('has_options', 'asc');
$entityCollection->setOrder('entity_id', 'asc');
$entityCollection->setStoreId(Store::DEFAULT_STORE_ID);
$this->_prepareEntityCollection($entityCollection);
$this->paginateCollection($page, $this->getItemsPerPage());
Expand Down
21 changes: 15 additions & 6 deletions app/code/Magento/CatalogImportExport/Model/Import/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,10 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
/** @var array */
protected $productUrlSuffix = [];

/** @var array */
/**
* @var array
* @deprecated
*/
protected $productUrlKeys = [];

/**
Expand Down Expand Up @@ -1508,6 +1511,10 @@ protected function _saveProducts()
}
$rowScope = $this->getRowScope($rowData);

if (empty($rowData[self::URL_KEY])) {
$rowData[self::URL_KEY] = $this->getUrlKey($rowData);
}

$rowSku = $rowData[self::COL_SKU];

if (null === $rowSku) {
Expand Down Expand Up @@ -2562,12 +2569,14 @@ protected function getProductUrlSuffix($storeId = null)
protected function getUrlKey($rowData)
{
if (!empty($rowData[self::URL_KEY])) {
$this->productUrlKeys[$rowData[self::COL_SKU]] = $rowData[self::URL_KEY];
return $rowData[self::URL_KEY];
}

if (!empty($rowData[self::COL_NAME])) {
return $this->productUrl->formatUrlKey($rowData[self::COL_NAME]);
}
$urlKey = !empty($this->productUrlKeys[$rowData[self::COL_SKU]])
? $this->productUrlKeys[$rowData[self::COL_SKU]]
: $this->productUrl->formatUrlKey($rowData[self::COL_NAME]);
return $urlKey;

return '';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ public function testExportCountZeroBreakInternalCalls()
$this->product->expects($this->once())->method('_prepareEntityCollection')->with($this->abstractCollection);
$this->product->expects($this->once())->method('getItemsPerPage')->willReturn($itemsPerPage);
$this->product->expects($this->once())->method('paginateCollection')->with($page, $itemsPerPage);
$this->abstractCollection->expects($this->once())->method('setOrder')->with('has_options', 'asc');
$this->abstractCollection->expects($this->once())->method('setOrder')->with('entity_id', 'asc');
$this->abstractCollection->expects($this->once())->method('setStoreId')->with(Store::DEFAULT_STORE_ID);

$this->abstractCollection->expects($this->once())->method('count')->willReturn(0);
Expand Down Expand Up @@ -434,7 +434,7 @@ public function testExportCurPageEqualToLastBreakInternalCalls()
$this->product->expects($this->once())->method('_prepareEntityCollection')->with($this->abstractCollection);
$this->product->expects($this->once())->method('getItemsPerPage')->willReturn($itemsPerPage);
$this->product->expects($this->once())->method('paginateCollection')->with($page, $itemsPerPage);
$this->abstractCollection->expects($this->once())->method('setOrder')->with('has_options', 'asc');
$this->abstractCollection->expects($this->once())->method('setOrder')->with('entity_id', 'asc');
$this->abstractCollection->expects($this->once())->method('setStoreId')->with(Store::DEFAULT_STORE_ID);

$this->abstractCollection->expects($this->once())->method('count')->willReturn(1);
Expand Down
76 changes: 76 additions & 0 deletions app/code/Magento/CatalogInventory/Setup/UpgradeData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\CatalogInventory\Setup;

use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\Framework\Indexer\AbstractProcessor;
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Store\Model\StoreManagerInterface;

/**
* Upgrade Data script
* @codeCoverageIgnore
*/
class UpgradeData implements UpgradeDataInterface
{
/**
* @var StockConfigurationInterface
*/
private $configuration;

/**
* @var AbstractProcessor
*/
private $indexerProcessor;

/**
* @var StoreManagerInterface
*/
private $storeManager;

/**
* @param StockConfigurationInterface $configuration
* @param StoreManagerInterface $storeManager
* @param AbstractProcessor $indexerProcessor
*/
public function __construct(
StockConfigurationInterface $configuration,
StoreManagerInterface $storeManager,
AbstractProcessor $indexerProcessor
) {
$this->configuration = $configuration;
$this->storeManager = $storeManager;
$this->indexerProcessor = $indexerProcessor;
}

/**
* {@inheritdoc}
*/
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
if (version_compare($context->getVersion(), '2.0.2') < 0) {
$this->upgradeCatalogInventoryStockItem($setup);
}
$setup->endSetup();
}

/**
* @param ModuleDataSetupInterface $setup
* @return void
*/
private function upgradeCatalogInventoryStockItem($setup)
{
$setup->getConnection()->update(
$setup->getTable('cataloginventory_stock_item'),
['website_id' => $this->configuration->getDefaultScopeId()],
['website_id = ?' => $this->storeManager->getWebsite()->getId()]
);
$this->indexerProcessor->getIndexer()->invalidate();
}
}
5 changes: 5 additions & 0 deletions app/code/Magento/CatalogInventory/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,9 @@
<type name="Magento\Catalog\Api\ProductRepositoryInterface">
<plugin name="catalogInventoryAroundSave" sortOrder="20" type="Magento\CatalogInventory\Model\Plugin\AroundProductRepositorySave"/>
</type>
<type name="Magento\CatalogInventory\Setup\UpgradeData">
<arguments>
<argument name="indexerProcessor" xsi:type="object">Magento\CatalogInventory\Model\Indexer\Stock\Processor</argument>
</arguments>
</type>
</config>
2 changes: 1 addition & 1 deletion app/code/Magento/CatalogInventory/etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_CatalogInventory" setup_version="2.0.1">
<module name="Magento_CatalogInventory" setup_version="2.0.2">
<sequence>
<module name="Magento_Catalog"/>
</sequence>
Expand Down
24 changes: 22 additions & 2 deletions app/code/Magento/CatalogWidget/Block/Product/ProductsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\CatalogWidget\Block\Product;

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

/**
* Catalog Products List widget block
Expand Down Expand Up @@ -81,6 +80,11 @@ class ProductsList extends \Magento\Catalog\Block\Product\AbstractProduct implem
*/
protected $conditionsHelper;

/**
* @var PriceCurrencyInterface
*/
private $priceCurrency;

/**
* @param \Magento\Catalog\Block\Product\Context $context
* @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory
Expand Down Expand Up @@ -144,6 +148,7 @@ public function getCacheKeyInfo()

return [
'CATALOG_PRODUCTS_LIST_WIDGET',
$this->getPriceCurrency()->getCurrencySymbol(),
$this->_storeManager->getStore()->getId(),
$this->_design->getDesignTheme()->getId(),
$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_GROUP),
Expand Down Expand Up @@ -351,4 +356,19 @@ public function getTitle()
{
return $this->getData('title');
}

/**
* @return PriceCurrencyInterface
*
* @deprecated
*/
private function getPriceCurrency()
{
if ($this->priceCurrency === null) {
$this->priceCurrency = \Magento\Framework\App\ObjectManager::getInstance()
->get(PriceCurrencyInterface::class);
}
return $this->priceCurrency;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Catalog\Model\Product\Visibility;
use Magento\Framework\Pricing\PriceCurrencyInterface;

/**
* Class ProductsListTest
Expand Down Expand Up @@ -72,6 +73,11 @@ class ProductsListTest extends \PHPUnit_Framework_TestCase
*/
protected $layout;

/**
* @var PriceCurrencyInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $priceCurrency;

protected function setUp()
{
$this->collectionFactory =
Expand Down Expand Up @@ -105,11 +111,13 @@ protected function setUp()
);
$this->request = $arguments['context']->getRequest();
$this->layout = $arguments['context']->getLayout();
$this->priceCurrency = $this->getMock(PriceCurrencyInterface::class);

$this->productsList = $objectManagerHelper->getObject(
\Magento\CatalogWidget\Block\Product\ProductsList::class,
$arguments
);
$objectManagerHelper->setBackwardCompatibleProperty($this->productsList, 'priceCurrency', $this->priceCurrency);
}

public function testGetCacheKeyInfo()
Expand All @@ -130,9 +138,11 @@ public function testGetCacheKeyInfo()
$this->request->expects($this->once())->method('getParam')->with('page_number')->willReturn(1);

$this->request->expects($this->once())->method('getParams')->willReturn('request_params');
$this->priceCurrency->expects($this->once())->method('getCurrencySymbol')->willReturn('$');

$cacheKey = [
'CATALOG_PRODUCTS_LIST_WIDGET',
'$',
1,
'blank',
'context_group',
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/ConfigurableProduct/Model/LinkManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function addChild($sku, $childSku)
}

$childrenIds[] = $child->getId();
$product->setAssociatedProductIds($childrenIds);
$product->getExtensionAttributes()->setConfigurableProductLinks($childrenIds);
$product->save();
return true;
}
Expand Down Expand Up @@ -132,7 +132,7 @@ public function removeChild($sku, $childSku)
if (count($options) == count($ids)) {
throw new NoSuchEntityException(__('Requested option doesn\'t exist'));
}
$product->addData(['associated_product_ids' => $ids]);
$product->getExtensionAttributes()->setConfigurableProductLinks($ids);
$product->save();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace Magento\ConfigurableProduct\Test\Unit\Model;

use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
use Magento\ConfigurableProduct\Test\Unit\Model\Product\ProductExtensionAttributes;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -162,7 +163,15 @@ public function testAddChild()
->will(
$this->returnValue([0 => [1, 2, 3]])
);
$configurable->expects($this->once())->method('__call')->with('setAssociatedProductIds', [[1, 2, 3, 999]]);

$extensionAttributes = $this->getMockBuilder(ProductExtensionAttributes::class)
->setMethods(['setConfigurableProductLinks'])
->disableOriginalConstructor()
->getMockForAbstractClass();

$configurable->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
$extensionAttributes->expects($this->once())->method('setConfigurableProductLinks')->willReturnSelf();

$configurable->expects($this->once())->method('save');

$this->assertTrue(true, $this->object->addChild($productSku, $childSku));
Expand Down Expand Up @@ -206,7 +215,7 @@ public function testRemoveChild()
$childSku = 'simple_10';

$product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
->setMethods(['getTypeInstance', 'save', 'getTypeId', 'addData', '__wakeup'])
->setMethods(['getTypeInstance', 'save', 'getTypeId', 'addData', '__wakeup', 'getExtensionAttributes'])
->disableOriginalConstructor()
->getMock();

Expand Down Expand Up @@ -234,7 +243,14 @@ public function testRemoveChild()
$productType->expects($this->once())->method('getUsedProducts')
->will($this->returnValue([$option]));

$product->expects($this->once())->method('addData')->with(['associated_product_ids' => []]);
$extensionAttributes = $this->getMockBuilder(ProductExtensionAttributes::class)
->setMethods(['setConfigurableProductLinks'])
->disableOriginalConstructor()
->getMockForAbstractClass();

$product->expects($this->once())->method('getExtensionAttributes')->willReturn($extensionAttributes);
$extensionAttributes->expects($this->once())->method('setConfigurableProductLinks')->willReturnSelf();

$product->expects($this->once())->method('save');
$this->assertTrue($this->object->removeChild($productSku, $childSku));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ protected function prepareVariations()
'sku' => $product->getSku(),
'name' => $product->getName(),
'qty' => $this->getProductStockQty($product),
'price' => $currency->toCurrency(sprintf("%f", $price), ['display' => false]),
'price' => $price,
'price_string' => $currency->toCurrency(sprintf("%f", $price)),
'price_currency' => $this->locator->getStore()->getBaseCurrency()->getCurrencySymbol(),
'configurable_attribute' => $this->getJsonConfigurableAttributes($variationOptions),
Expand Down
Loading

0 comments on commit b2fcaba

Please sign in to comment.