Skip to content

Commit

Permalink
Merge pull request #678 from magento-dragons/BugFestW1
Browse files Browse the repository at this point in the history
[DRAGONS][Troll][GoInc][South][API][EPAM] Bug Fixes and Stories
  • Loading branch information
Kasian,Andrii(akasian) committed Oct 6, 2015
2 parents b43a7c4 + a6a2762 commit 4517819
Show file tree
Hide file tree
Showing 328 changed files with 15,225 additions and 1,778 deletions.
13 changes: 13 additions & 0 deletions app/code/Magento/Backend/Block/Dashboard/Orders/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ protected function _prepareCollection()
return parent::_prepareCollection();
}

/**
* Process collection after loading
*
* @return $this
*/
protected function _afterLoadCollection()
{
foreach ($this->getCollection() as $item) {
$item->getCustomer() ?: $item->setCustomer('Guest');
}
return $this;
}

/**
* Prepares page sizes for dashboard grid with las 5 orders
*
Expand Down
6 changes: 3 additions & 3 deletions app/code/Magento/Backend/Block/Store/Switcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function isWebsiteSelected(\Magento\Store\Model\Website $website)
public function getWebsiteId()
{
if (!$this->hasData('website_id')) {
$this->setData('website_id', $this->getRequest()->getParam($this->getWebsiteVarName()));
$this->setData('website_id', (int)$this->getRequest()->getParam($this->getWebsiteVarName()));
}
return $this->getData('website_id');
}
Expand Down Expand Up @@ -289,7 +289,7 @@ public function isStoreGroupSelected(\Magento\Store\Model\Group $group)
public function getStoreGroupId()
{
if (!$this->hasData('store_group_id')) {
$this->setData('store_group_id', $this->getRequest()->getParam($this->getStoreGroupVarName()));
$this->setData('store_group_id', (int)$this->getRequest()->getParam($this->getStoreGroupVarName()));
}
return $this->getData('store_group_id');
}
Expand Down Expand Up @@ -339,7 +339,7 @@ public function getStores($group)
public function getStoreId()
{
if (!$this->hasData('store_id')) {
$this->setData('store_id', $this->getRequest()->getParam($this->getStoreVarName()));
$this->setData('store_id', (int)$this->getRequest()->getParam($this->getStoreVarName()));
}
return $this->getData('store_id');
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ require(['jquery'], function(jQuery){
if (confirm("<?php /* @escapeNotVerified */ echo __('Please confirm scope switching. All data that hasn\'t been saved will be lost.') ?>")) {
reload();
} else {
obj.value = '<?php /* @escapeNotVerified */ echo $block->getStoreId() ?>';
obj.value = '<?php echo $block->escapeHtml($block->getStoreId()) ?>';
}
<?php else: ?>
reload();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions app/code/Magento/Catalog/Api/CategoryManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,11 @@ public function getTree($rootCategoryId = null, $depth = null);
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function move($categoryId, $parentId, $afterId = null);

/**
* Provide the number of category count
*
* @return int
*/
public function getCount();
}
20 changes: 20 additions & 0 deletions app/code/Magento/Catalog/Api/ProductManagementInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Api;

/**
* @api
*/
interface ProductManagementInterface
{
/**
* Provide the number of product count
*
* @param null|int $status
* @return int
*/
public function getCount($status = null);
}
22 changes: 10 additions & 12 deletions app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
namespace Magento\Catalog\Block\Product\ProductList;

use Magento\Catalog\Helper\Data;
use Magento\Catalog\Model\Product\ProductList\Toolbar as ToolbarModel;

/**
Expand Down Expand Up @@ -672,19 +671,18 @@ public function getPagerHtml()
*/
public function getWidgetOptionsJson(array $customOptions = [])
{
$postData = $this->_postDataHelper->getPostData(
$this->getPagerUrl(),
[\Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $this->getPagerEncodedUrl()]
);
$defaultMode = $this->_productListHelper->getDefaultViewMode($this->getModes());
$options = [
'modeCookie' => ToolbarModel::MODE_COOKIE_NAME,
'directionCookie' => ToolbarModel::DIRECTION_COOKIE_NAME,
'orderCookie' => ToolbarModel::ORDER_COOKIE_NAME,
'limitCookie' => ToolbarModel::LIMIT_COOKIE_NAME
'mode' => ToolbarModel::MODE_PARAM_NAME,
'direction' => ToolbarModel::DIRECTION_PARAM_NAME,
'order' => ToolbarModel::ORDER_PARAM_NAME,
'limit' => ToolbarModel::LIMIT_PARAM_NAME,
'modeDefault' => $defaultMode,
'directionDefault' => \Magento\Catalog\Helper\Product\ProductList::DEFAULT_SORT_DIRECTION,
'orderDefault' => $this->_productListHelper->getDefaultSortField(),
'limitDefault' => $this->_productListHelper->getDefaultLimitPerPageValue($defaultMode),
'url' => $this->getPagerUrl(),
];
if ($postData) {
$options['postData'] = json_decode($postData);
}
$options = array_replace_recursive($options, $customOptions);
return json_encode(['productListToolbarForm' => $options]);
}
Expand Down
4 changes: 3 additions & 1 deletion app/code/Magento/Catalog/Block/Product/View/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Magento\Catalog\Block\Product\View;

use Magento\Framework\Data\Collection;
use Magento\Catalog\Helper\Image;

class Gallery extends \Magento\Catalog\Block\Product\View\AbstractView
{
Expand Down Expand Up @@ -112,7 +113,8 @@ public function isMainImage($image)
*/
public function getImageAttribute($imageId, $attributeName, $default = null)
{
$attributes = $this->getConfigView()->getImageAttributes('Magento_Catalog', $imageId);
$attributes =
$this->getConfigView()->getMediaAttributes('Magento_Catalog', Image::MEDIA_TYPE_CONFIG_NODE, $imageId);
return isset($attributes[$attributeName]) ? $attributes[$attributeName] : $default;
}

Expand Down
12 changes: 9 additions & 3 deletions app/code/Magento/Catalog/Helper/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
*/
class Image extends AbstractHelper
{
/**
* Media config node
*/
const MEDIA_TYPE_CONFIG_NODE = 'images';

/**
* Current model
*
Expand Down Expand Up @@ -172,7 +177,7 @@ public function init($product, $imageId, $attributes = [])

$this->attributes = array_merge(
$attributes,
$this->getConfigView()->getImageAttributes('Magento_Catalog', $imageId)
$this->getConfigView()->getMediaAttributes('Magento_Catalog', self::MEDIA_TYPE_CONFIG_NODE, $imageId)
);

$this->setProduct($product);
Expand Down Expand Up @@ -425,13 +430,14 @@ public function placeholder($fileName)

/**
* Get Placeholder
*
* @param null|string $placeholder
* @return string
*/
public function getPlaceholder($placeholder = null)
{
if (!$this->_placeholder) {
$placeholder = $placeholder?: $this->_getModel()->getDestinationSubdir();
$placeholder = $placeholder ? : $this->_getModel()->getDestinationSubdir();
$this->_placeholder = 'Magento_Catalog::images/product/placeholder/' . $placeholder . '.jpg';
}
return $this->_placeholder;
Expand Down Expand Up @@ -810,7 +816,7 @@ public function getWidth()
*/
public function getHeight()
{
return $this->getAttribute('height') ?: $this->getAttribute('width');
return $this->getAttribute('height') ? : $this->getAttribute('width');
}

/**
Expand Down
80 changes: 0 additions & 80 deletions app/code/Magento/Catalog/Model/App/Action/ContextPlugin.php

This file was deleted.

18 changes: 17 additions & 1 deletion app/code/Magento/Catalog/Model/CategoryManagement.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace Magento\Catalog\Model;

use Magento\Catalog\Model\Resource\Category\CollectionFactory;

class CategoryManagement implements \Magento\Catalog\Api\CategoryManagementInterface
{
/**
Expand All @@ -22,13 +24,16 @@ class CategoryManagement implements \Magento\Catalog\Api\CategoryManagementInter
/**
* @param \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository
* @param Category\Tree $categoryTree
* @param CollectionFactory $categoriesFactory
*/
public function __construct(
\Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,
\Magento\Catalog\Model\Category\Tree $categoryTree
\Magento\Catalog\Model\Category\Tree $categoryTree,
\Magento\Catalog\Model\Resource\Category\CollectionFactory $categoriesFactory
) {
$this->categoryRepository = $categoryRepository;
$this->categoryTree = $categoryTree;
$this->categoriesFactory = $categoriesFactory;
}

/**
Expand Down Expand Up @@ -72,4 +77,15 @@ public function move($categoryId, $parentId, $afterId = null)
}
return true;
}

/**
* {@inheritdoc}
*/
public function getCount()
{
$categories = $this->categoriesFactory->create();
/** @var \Magento\Catalog\Model\Resource\Category\Collection $categories */
$categories->addAttributeToFilter('parent_id', ['gt' => 0]);
return $categories->getSize();
}
}
41 changes: 41 additions & 0 deletions app/code/Magento/Catalog/Model/ImageExtractor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Model;

use Magento\Catalog\Model\Product\Attribute\Backend\Media\ImageEntryConverter;
use Magento\Catalog\Helper\Image;

class ImageExtractor implements \Magento\Framework\View\Xsd\Media\TypeDataExtractorInterface
{
/**
* Extract configuration data of images from the DOM structure
*
* @param \DOMElement $mediaNode
* @param string $mediaParentTag
* @return array
*/
public function process(\DOMElement $mediaNode, $mediaParentTag)
{
$result = [];
/** @var \DOMElement $node */
$moduleNameImage = $mediaNode->getAttribute('module');
foreach ($mediaNode->getElementsByTagName(ImageEntryConverter::MEDIA_TYPE_CODE) as $node) {
$imageId = $node->getAttribute('id');
$result[$mediaParentTag][$moduleNameImage][Image::MEDIA_TYPE_CONFIG_NODE][$imageId]['type']
= $node->getAttribute('type');
foreach ($node->childNodes as $attribute) {
if ($attribute->nodeType != XML_ELEMENT_NODE) {
continue;
}
$nodeValue = $attribute->nodeValue;
$result[$mediaParentTag][$moduleNameImage][Image::MEDIA_TYPE_CONFIG_NODE][$imageId][$attribute->tagName]
= $nodeValue;
}
}

return $result;
}
}
2 changes: 1 addition & 1 deletion app/code/Magento/Catalog/Model/Product/Image/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected function getData()
'area' => Area::AREA_FRONTEND,
'themeModel' => $theme,
]);
$images = $config->getImages('Magento_Catalog');
$images = $config->getMediaEntities('Magento_Catalog', ImageHelper::MEDIA_TYPE_CONFIG_NODE);
foreach ($images as $imageId => $imageData) {
$this->data[$theme->getCode() . $imageId] = array_merge(['id' => $imageId], $imageData);
}
Expand Down
Loading

0 comments on commit 4517819

Please sign in to comment.