Skip to content

Commit 53b4343

Browse files
author
Stanislav Idolov
committed
Merge remote-tracking branch 'mainline/develop' into bugs
2 parents c519272 + cb6cded commit 53b4343

File tree

143 files changed

+3629
-2286
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

143 files changed

+3629
-2286
lines changed

app/code/Magento/Bundle/Block/Checkout/Cart/Item/Renderer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Renderer extends \Magento\Checkout\Block\Cart\Item\Renderer
2626
* @param \Magento\Framework\View\Element\Template\Context $context
2727
* @param \Magento\Catalog\Helper\Product\Configuration $productConfig
2828
* @param \Magento\Checkout\Model\Session $checkoutSession
29-
* @param \Magento\Catalog\Helper\Image $imageHelper
29+
* @param \Magento\Catalog\Helper\Image $imageBuilder
3030
* @param \Magento\Framework\Url\Helper\Data $urlHelper
3131
* @param \Magento\Framework\Message\ManagerInterface $messageManager
3232
* @param PriceCurrencyInterface $priceCurrency
@@ -39,7 +39,7 @@ public function __construct(
3939
\Magento\Framework\View\Element\Template\Context $context,
4040
\Magento\Catalog\Helper\Product\Configuration $productConfig,
4141
\Magento\Checkout\Model\Session $checkoutSession,
42-
\Magento\Catalog\Helper\Image $imageHelper,
42+
\Magento\Catalog\Block\Product\ImageBuilder $imageBuilder,
4343
\Magento\Framework\Url\Helper\Data $urlHelper,
4444
\Magento\Framework\Message\ManagerInterface $messageManager,
4545
PriceCurrencyInterface $priceCurrency,
@@ -52,7 +52,7 @@ public function __construct(
5252
$context,
5353
$productConfig,
5454
$checkoutSession,
55-
$imageHelper,
55+
$imageBuilder,
5656
$urlHelper,
5757
$messageManager,
5858
$priceCurrency,

app/code/Magento/Bundle/view/frontend/templates/catalog/product/view/summary.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</div>
2121
<div class="content">
2222
<div class="bundle-info">
23-
<?php echo $block->getLayout()->createBlock('Magento\Catalog\Block\Product\Image')->init($_product, 'bundled_product_customization_page')->toHtml() ?>
23+
<?php echo $block->getImage($_product, 'bundled_product_customization_page')->toHtml(); ?>
2424
<div class="product-details">
2525
<strong class="product name"><?php echo $block->escapeHtml($_product->getName()) ?></strong>
2626
<?php if ($_product->getIsSalable()): ?>

app/code/Magento/Catalog/Block/Product/AbstractProduct.php

Lines changed: 17 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class AbstractProduct extends \Magento\Framework\View\Element\Template
101101
public function __construct(\Magento\Catalog\Block\Product\Context $context, array $data = [])
102102
{
103103
$this->_imageHelper = $context->getImageHelper();
104+
$this->imageBuilder = $context->getImageBuilder();
104105
$this->_compareProduct = $context->getCompareProduct();
105106
$this->_wishlistHelper = $context->getWishlistHelper();
106107
$this->_cartHelper = $context->getCartHelper();
@@ -241,28 +242,6 @@ protected function _addProductAttributesAndPrices(\Magento\Catalog\Model\Resourc
241242
->addUrlRewrite();
242243
}
243244

244-
/**
245-
* Retrieve given media attribute label or product name if no label
246-
*
247-
* @param \Magento\Catalog\Model\Product $product
248-
* @param string $mediaAttributeCode
249-
*
250-
* @return string
251-
*/
252-
public function getImageLabel($product = null, $mediaAttributeCode = 'image')
253-
{
254-
if ($product === null) {
255-
$product = $this->getProduct();
256-
}
257-
258-
$label = $product->getData($mediaAttributeCode . '_label');
259-
if (empty($label)) {
260-
$label = $product->getName();
261-
}
262-
263-
return $label;
264-
}
265-
266245
/**
267246
* Retrieve Product URL using UrlDataObject
268247
*
@@ -398,138 +377,6 @@ public function displayProductStockStatus()
398377
return (bool) $statusInfo->getDisplayStatus();
399378
}
400379

401-
/**
402-
* Product thumbnail image url getter
403-
*
404-
* @param \Magento\Catalog\Model\Product $product
405-
* @return string
406-
*/
407-
public function getThumbnailUrl($product)
408-
{
409-
return (string) $this->_imageHelper->init($product, 'thumbnail')
410-
->resize($this->getThumbnailSize());
411-
}
412-
413-
/**
414-
* Thumbnail image size getter
415-
*
416-
* @return int
417-
*/
418-
public function getThumbnailSize()
419-
{
420-
return $this->getVar('product_thumbnail_image_size', 'Magento_Catalog');
421-
}
422-
423-
/**
424-
* Product thumbnail image sidebar url getter
425-
*
426-
* @param \Magento\Catalog\Model\Product $product
427-
* @return string
428-
*/
429-
public function getThumbnailSidebarUrl($product)
430-
{
431-
return (string) $this->_imageHelper->init($product, 'thumbnail')
432-
->resize($this->getThumbnailSidebarSize());
433-
}
434-
435-
/**
436-
* Thumbnail image sidebar size getter
437-
*
438-
* @return int
439-
*/
440-
public function getThumbnailSidebarSize()
441-
{
442-
return $this->getVar('product_thumbnail_image_sidebar_size', 'Magento_Catalog');
443-
}
444-
445-
/**
446-
* Product small image url getter
447-
*
448-
* @param \Magento\Catalog\Model\Product $product
449-
* @return string
450-
*/
451-
public function getSmallImageUrl($product)
452-
{
453-
return (string) $this->_imageHelper->init($product, 'small_image')
454-
->resize($this->getSmallImageSize());
455-
}
456-
457-
/**
458-
* Small image size getter
459-
*
460-
* @return int
461-
*/
462-
public function getSmallImageSize()
463-
{
464-
return $this->getVar('product_small_image_size', 'Magento_Catalog');
465-
}
466-
467-
/**
468-
* Product small image sidebar url getter
469-
*
470-
* @param \Magento\Catalog\Model\Product $product
471-
* @return string
472-
*/
473-
public function getSmallImageSidebarUrl($product)
474-
{
475-
return (string) $this->_imageHelper->init($product, 'small_image')
476-
->resize($this->getSmallImageSidebarSize());
477-
}
478-
479-
/**
480-
* Small image sidebar size getter
481-
*
482-
* @return int
483-
*/
484-
public function getSmallImageSidebarSize()
485-
{
486-
return $this->getVar('product_small_image_sidebar_size', 'Magento_Catalog');
487-
}
488-
489-
/**
490-
* Product base image url getter
491-
*
492-
* @param \Magento\Catalog\Model\Product $product
493-
* @return string
494-
*/
495-
public function getBaseImageUrl($product)
496-
{
497-
return (string) $this->_imageHelper->init($product, 'image')
498-
->resize($this->getBaseImageSize());
499-
}
500-
501-
/**
502-
* Base image size getter
503-
*
504-
* @return int
505-
*/
506-
public function getBaseImageSize()
507-
{
508-
return $this->getVar('product_base_image_size', 'Magento_Catalog');
509-
}
510-
511-
/**
512-
* Product base image icon url getter
513-
*
514-
* @param \Magento\Catalog\Model\Product $product
515-
* @return string
516-
*/
517-
public function getBaseImageIconUrl($product)
518-
{
519-
return (string) $this->_imageHelper->init($product, 'image')
520-
->resize($this->getBaseImageIconSize());
521-
}
522-
523-
/**
524-
* Base image icon size getter
525-
*
526-
* @return int
527-
*/
528-
public function getBaseImageIconSize()
529-
{
530-
return $this->getVar('product_base_image_icon_size', 'Magento_Catalog');
531-
}
532-
533380
/**
534381
* Get random string
535382
*
@@ -642,4 +489,20 @@ protected function getDetailsRendererList()
642489
'details.renderers'
643490
);
644491
}
492+
493+
/**
494+
* Retrieve product image
495+
*
496+
* @param \Magento\Catalog\Model\Product $product
497+
* @param string $imageId
498+
* @param array $attributes
499+
* @return \Magento\Catalog\Block\Product\Image
500+
*/
501+
public function getImage($product, $imageId, $attributes = [])
502+
{
503+
return $this->imageBuilder->setProduct($product)
504+
->setImageId($imageId)
505+
->setAttributes($attributes)
506+
->create();
507+
}
645508
}

app/code/Magento/Catalog/Block/Product/Context.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class Context extends \Magento\Framework\View\Element\Template\Context
7171
*/
7272
protected $pageConfig;
7373

74+
/**
75+
* @var ImageBuilder
76+
*/
77+
protected $imageBuilder;
78+
7479
/**
7580
* @param \Magento\Framework\App\RequestInterface $request
7681
* @param \Magento\Framework\View\LayoutInterface $layout
@@ -106,6 +111,7 @@ class Context extends \Magento\Framework\View\Element\Template\Context
106111
* @param \Magento\Wishlist\Helper\Data $wishlistHelper
107112
* @param \Magento\Catalog\Helper\Product\Compare $compareProduct
108113
* @param \Magento\Catalog\Helper\Image $imageHelper
114+
* @param ImageBuilder $imageBuilder
109115
* @param ReviewRendererInterface $reviewRenderer
110116
* @param \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
111117
*
@@ -146,10 +152,12 @@ public function __construct(
146152
\Magento\Wishlist\Helper\Data $wishlistHelper,
147153
\Magento\Catalog\Helper\Product\Compare $compareProduct,
148154
\Magento\Catalog\Helper\Image $imageHelper,
155+
\Magento\Catalog\Block\Product\ImageBuilder $imageBuilder,
149156
ReviewRendererInterface $reviewRenderer,
150157
\Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry
151158
) {
152159
$this->imageHelper = $imageHelper;
160+
$this->imageBuilder = $imageBuilder;
153161
$this->compareProduct = $compareProduct;
154162
$this->wishlistHelper = $wishlistHelper;
155163
$this->cartHelper = $cartHelper;
@@ -237,6 +245,14 @@ public function getImageHelper()
237245
return $this->imageHelper;
238246
}
239247

248+
/**
249+
* @return \Magento\Catalog\Block\Product\ImageBuilder
250+
*/
251+
public function getImageBuilder()
252+
{
253+
return $this->imageBuilder;
254+
}
255+
240256
/**
241257
* @return \Magento\Framework\Math\Random
242258
*/

app/code/Magento/Catalog/Block/Product/Image.php

Lines changed: 18 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -6,99 +6,44 @@
66
namespace Magento\Catalog\Block\Product;
77

88
/**
9-
* @method setImageType(string)
10-
* @method string getImageType()
11-
* @method setImageWidth(string)
12-
* @method string getImageWidth()
13-
* @method setImageHeight(string)
14-
* @method string getImageHeight()
15-
* @method setImageLabel(string)
16-
* @method string getImageLabel()
17-
* @method setAddWhiteBorders(bool)
18-
* @method bool getAddWhiteBorders()
19-
* @method \Magento\Catalog\Helper\Image getImageHelper()
20-
* @method setImageHelper(\Magento\Catalog\Helper\Image $imageHelper)
21-
* @method \Magento\Catalog\Model\Product getProduct()
22-
*
23-
* Product image block
24-
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
25-
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
26-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
9+
* @method string getImageUrl()
10+
* @method string getWidth()
11+
* @method string getHeight()
12+
* @method string getLabel()
13+
* @method mixed getResizedImageWidth()
14+
* @method mixed getResizedImageHeight()
15+
* @method float getRatio()
16+
* @method string getCustomAttributes()
2717
*/
2818
class Image extends \Magento\Framework\View\Element\Template
2919
{
3020
/**
31-
* Template image only
32-
*
33-
* @var string
21+
* @var \Magento\Catalog\Helper\Image
3422
*/
35-
protected $_templateImage = 'Magento_Catalog::product/image.phtml';
23+
protected $imageHelper;
3624

3725
/**
38-
* Template image with html frame border
39-
*
40-
* @var string
26+
* @var \Magento\Catalog\Model\Product
4127
*/
42-
protected $_templateWithBorders = 'Magento_Catalog::product/image_with_borders.phtml';
28+
protected $product;
4329

4430
/**
45-
* @var \Magento\Catalog\Model\Product\Image\View
31+
* @var array
4632
*/
47-
protected $_productImageView;
33+
protected $attributes = [];
4834

4935
/**
5036
* @param \Magento\Framework\View\Element\Template\Context $context
51-
* @param \Magento\Catalog\Model\Product\Image\View $productImageView
5237
* @param array $data
5338
*/
5439
public function __construct(
5540
\Magento\Framework\View\Element\Template\Context $context,
56-
\Magento\Catalog\Model\Product\Image\View $productImageView,
5741
array $data = []
5842
) {
59-
$this->_productImageView = $productImageView;
60-
parent::__construct($context, $data);
61-
}
62-
63-
/**
64-
* Initialize model
65-
*
66-
* @param \Magento\Catalog\Model\Product $product
67-
* @param string $location
68-
* @param string $module
69-
* @return \Magento\Catalog\Block\Product\Image
70-
*/
71-
public function init(\Magento\Catalog\Model\Product $product, $location, $module = 'Magento_Catalog')
72-
{
73-
$this->_productImageView->init($product, $location, $module);
74-
$this->_initTemplate();
75-
return $this;
76-
}
77-
78-
/**
79-
* Select a template based on white_border flag
80-
*
81-
* @return \Magento\Catalog\Block\Product\Image
82-
*/
83-
protected function _initTemplate()
84-
{
85-
if (null === $this->getTemplate()) {
86-
$template = $this->getProductImageView()
87-
->isWhiteBorders() ? $this
88-
->_templateImage : $this
89-
->_templateWithBorders;
90-
$this->setTemplate($template);
43+
if (isset($data['template'])) {
44+
$this->setTemplate($data['template']);
45+
unset($data['template']);
9146
}
92-
return $this;
93-
}
94-
95-
/**
96-
* Getter for product image view model
97-
*
98-
* @return \Magento\Catalog\Model\Product\Image\View
99-
*/
100-
public function getProductImageView()
101-
{
102-
return $this->_productImageView;
47+
parent::__construct($context, $data);
10348
}
10449
}

0 commit comments

Comments
 (0)