Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:magento/magento2ce into MAGETWO-…
Browse files Browse the repository at this point in the history
…65182
  • Loading branch information
rganin committed Mar 21, 2017
2 parents a744e7d + 2613378 commit bee7998
Show file tree
Hide file tree
Showing 48 changed files with 1,783 additions and 99 deletions.
3 changes: 2 additions & 1 deletion app/code/Magento/Backend/Block/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*
* @method \Magento\Backend\Block\Menu setAdditionalCacheKeyInfo(array $cacheKeyInfo)
* @method array getAdditionalCacheKeyInfo()
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Menu extends \Magento\Backend\Block\Template
{
Expand Down Expand Up @@ -381,7 +382,7 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
$itemName = substr($menuId, strrpos($menuId, '::') + 2);
$itemClass = str_replace('_', '-', strtolower($itemName));

if (count($colBrakes) && $colBrakes[$itemPosition]['colbrake']) {
if (count($colBrakes) && $colBrakes[$itemPosition]['colbrake'] && $itemPosition != 1) {
$output .= '</ul></li><li class="column"><ul role="menu">';
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
<?php
$idSuffix = $block->getIdSuffix() ? $block->getIdSuffix() : '';
/** @var \Magento\Bundle\Pricing\Render\FinalPriceBox $block */
$productId = $block->getSaleableItem()->getId();


/** @var \Magento\Bundle\Pricing\Price\FinalPrice $finalPriceModel */
$finalPriceModel = $block->getPrice();
$minimalPrice = $finalPriceModel->getMinimalPrice();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ public function addCategoryFilter(\Magento\Catalog\Model\Category $category)
* Filter Product by Categories
*
* @param array $categoriesFilter
* @return $this
*/
public function addCategoriesFilter(array $categoriesFilter)
{
Expand All @@ -876,6 +877,7 @@ public function addCategoriesFilter(array $categoriesFilter)
];
$this->getSelect()->where($this->getConnection()->prepareSqlCondition('e.entity_id' , $selectCondition));
}
return $this;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Integration/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function mapResources(array $resources)
foreach ($resources as $resource) {
$item = [];
$item['attr']['data-id'] = $resource['id'];
$item['data'] = $resource['title'];
$item['data'] = __($resource['title']);
$item['children'] = [];
if (isset($resource['children'])) {
$item['state'] = 'open';
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Rule/Model/Condition/AbstractCondition.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,8 @@ public function getValueName()
}
if (!empty($valueArr)) {
$value = implode(', ', $valueArr);
} elseif (is_array($value)) {
$value = implode(', ', $value);
}
return $value;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\AdvancedPricingImportExport\Test\Constraint;

use Magento\Mtf\Constraint\AbstractConstraint;
use Magento\Mtf\Fixture\InjectableFixture;
use Magento\Mtf\Util\Command\File\ExportInterface;

/**
* Assert that exported file with advanced pricing options contains product data.
*/
class AssertExportAdvancedPricing extends AbstractConstraint
{
/**
* Export data.
*
* @var array
*/
private $exportData;

/**
* Assert that exported file with advanced pricing options contains product data.
*
* @param ExportInterface $export
* @param array $products
* @param array $exportedFields
* @return void
*/
public function processAssert(
ExportInterface $export,
array $products,
array $exportedFields
) {
$this->exportData = $export->getLatest();
foreach ($products as $product) {
$regexps = $this->prepareRegexpsForCheck($exportedFields, $product);
\PHPUnit_Framework_Assert::assertTrue(
$this->isProductDataExists($regexps),
'A product with name ' . $product->getName() . ' was not found in exported file.'
);
}
}

/**
* Returns a string representation of the object.
*
* @return string
*/
public function toString()
{
return 'A product(s) with correct data was found in exported file.';
}

/**
* Prepare regular expressions for product data in exported file.
*
* @param array $fields
* @param InjectableFixture $product
* @return array
*/
private function prepareRegexpsForCheck(
array $fields,
InjectableFixture $product
) {
$regexpsForCheck = [];
$tierPrices = count($product->getData()['tier_price']);
for ($i = 0; $i < $tierPrices; $i++) {
$regexp = '/';
foreach ($fields as $field) {
if (strpos($field, 'tier_price') !== false) {
$replace = ($field == 'tier_price' || $field == 'tier_price_qty') ? 'tier_' : 'tier_price_';
$regexp .= preg_replace(
'/[\[\]]/',
'.*',
'.*(' . $product->getData()['tier_price'][$i][str_replace($replace, '', $field)] . ')'
);
} else {
$regexp .= '.*(' . $product->getData($field) . ').*';
}
}
$regexp .= '/U';

$regexpsForCheck[] = $regexp;
}

return $regexpsForCheck;
}

/**
* Check product data existing in exported file.
*
* @param array $data
* @return bool
*/
private function isProductDataExists(array $data)
{
foreach ($data as $regexp) {
preg_match($regexp, $this->exportData->getContent(), $matches);
if (empty($matches)) {
return false;
}
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<?php
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\AdvancedPricingImportExport\Test\Constraint;

use Magento\Mtf\Constraint\AbstractConstraint;
use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit;
use Magento\ImportExport\Test\Fixture\ImportData;

/**
* Check imported advanced prices are correct.
*/
class AssertImportAdvancedPricing extends AbstractConstraint
{
/**
* Array keys mapping for csv file.
*
* @var array
*/
private $mappingData = [
'sku' => 'sku',
'tier_price' => 'price',
'tier_price_qty' => 'price_qty',
'tier_price_website' => 'website',
'tier_price_customer_group' => 'customer_group',
'tier_price_value_type' => 'value_type'
];

/**
* Edit page on backend.
*
* @var CatalogProductEdit
*/
private $catalogProductEdit;

/**
* Import fixture.
*
* @var ImportData
*/
private $import;

/**
* Assert imported advanced prices are correct.
*
* @param CatalogProductEdit $catalogProductEdit
* @param ImportData $import
* @return void
*/
public function processAssert(
CatalogProductEdit $catalogProductEdit,
ImportData $import
) {
$this->catalogProductEdit = $catalogProductEdit;
$this->import = $import;

$resultArrays = $this->getPreparePrices();

\PHPUnit_Framework_Assert::assertEquals(
$resultArrays['pageData'],
$resultArrays['csvData'],
'Tier prices from page and csv are not match.'
);
}

/**
* Prepare arrays for compare.
*
* @return array
*/
private function getPreparePrices()
{
$products = $this->import->getDataFieldConfig('import_file')['source']->getEntities();

// Prepare tier prices data from page form.
$resultProductArray = [];
foreach ($products as $product) {
$this->catalogProductEdit->open(['id' => $product->getId()]);
$advancedPricing = $this->catalogProductEdit->getProductForm()->openSection('advanced-pricing')
->getSection('advanced-pricing');
$tierPrices = $advancedPricing->getTierPriceForm()->getFieldsData();
$productSku = $product->getSku();
foreach ($tierPrices as $tierPrice) {
$resultProductArray[$productSku][] = $tierPrice;
}
}

// Prepare tier prices data from csv file.
$resultCsvArray = [];
if ($this->import->getBehavior() !== 'Delete') {
$resultCsvArray = $this->getResultCsv();
}

return ['pageData' => $resultProductArray, 'csvData' => $resultCsvArray];
}

/**
* Prepare array from csv file.
*
* @return array
*/
private function getResultCsv()
{
$csvData = $this->import->getDataFieldConfig('import_file')['source']->getCsv();

$csvKeys = [];
foreach (array_shift($csvData) as $csvKey) {
$csvKeys[] = isset($this->mappingData[$csvKey]) ? $this->mappingData[$csvKey] : $csvKey;
}

$resultCsvData = [];
foreach ($csvData as $csvRowData) {
$csvRowData = array_combine($csvKeys, $csvRowData);
$sku = $csvRowData['sku'];
unset($csvRowData['sku']);
$resultCsvData[$sku][] = $csvRowData;
}
return $resultCsvData;
}

/**
* Return string representation of object.
*
* @return string
*/
public function toString()
{
return 'Imported advanced prices are correct.';
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" ?>
<!--
/**
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
<repository class="Magento\ImportExport\Test\Repository\ExportData">
<dataset name="csv_with_advanced_pricing">
<field name="entity" xsi:type="string">Advanced Pricing</field>
<field name="file_format" xsi:type="string">CSV</field>
</dataset>
</repository>
</config>
Loading

0 comments on commit bee7998

Please sign in to comment.