File tree 5 files changed +24
-18
lines changed
Catalog/Model/Product/Configuration/Item
Checkout/Test/Unit/Block/Cart/Item
ConfigurableProduct/Model/Product/Configuration/Item
GroupedProduct/Model/Product/Configuration/Item
Wishlist/Block/Customer/Wishlist/Item/Column
5 files changed +24
-18
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ class ItemResolverComposite implements ItemResolverInterface
18
18
/** @var string[] */
19
19
private $ itemResolvers = [];
20
20
21
+ /** @var ItemResolverInterface[] */
22
+ private $ itemResolversInstances = [];
23
+
21
24
/**
22
25
* @param string[] $itemResolvers
23
26
*/
@@ -43,13 +46,16 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
43
46
}
44
47
45
48
/**
46
- * Get the instance of the item resolver by class name
49
+ * Get the instance of the item resolver by class name.
47
50
*
48
51
* @param string $className
49
52
* @return ItemResolverInterface
50
53
*/
51
54
private function getItemResolverInstance (string $ className )
52
55
{
53
- return ObjectManager::getInstance ()->get ($ className );
56
+ if (!isset ($ this ->itemResolversInstances [$ className ])) {
57
+ $ this ->itemResolversInstances [$ className ] = ObjectManager::getInstance ()->get ($ className );
58
+ }
59
+ return $ this ->itemResolversInstances [$ className ];
54
60
}
55
61
}
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ protected function setUp()
47
47
->getMock ();
48
48
$ context ->expects ($ this ->once ())
49
49
->method ('getLayout ' )
50
- ->will ($ this ->returnValue ( $ this -> layout ) );
50
+ ->willReturn ($ this ->layout );
51
51
52
52
$ this ->imageBuilder = $ this ->getMockBuilder (\Magento \Catalog \Block \Product \ImageBuilder::class)
53
53
->disableOriginalConstructor ()
Original file line number Diff line number Diff line change @@ -46,23 +46,23 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
46
46
* Show parent product thumbnail if it must be always shown according to the related setting in system config
47
47
* or if child thumbnail is not available.
48
48
*/
49
- $ parentItem = $ item ->getProduct ();
50
- $ config = $ this ->scopeConfig ->getValue (
49
+ $ parentProduct = $ item ->getProduct ();
50
+ $ configValue = $ this ->scopeConfig ->getValue (
51
51
self ::CONFIG_THUMBNAIL_SOURCE ,
52
52
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
53
53
);
54
54
55
55
$ childProduct = $ this ->getChildProduct ($ item );
56
- $ childThumbnail = $ childProduct ->getData ('thumbnail ' );
56
+ $ childThumb = $ childProduct ->getData ('thumbnail ' );
57
57
$ finalProduct =
58
- ($ config == Thumbnail::OPTION_USE_PARENT_IMAGE ) || (!$ childThumbnail || $ childThumbnail == 'no_selection ' )
59
- ? $ parentItem
58
+ ($ configValue == Thumbnail::OPTION_USE_PARENT_IMAGE ) || (!$ childThumb || $ childThumb == 'no_selection ' )
59
+ ? $ parentProduct
60
60
: $ childProduct ;
61
61
return $ finalProduct ;
62
62
}
63
63
64
64
/**
65
- * Get item configurable child product
65
+ * Get item configurable child product.
66
66
*
67
67
* @param ItemInterface $item
68
68
* @return Product
Original file line number Diff line number Diff line change @@ -44,24 +44,24 @@ public function getFinalProduct(ItemInterface $item) : ProductInterface
44
44
{
45
45
/**
46
46
* Show grouped product thumbnail if it must be always shown according to the related setting in system config
47
- * or if child product thumbnail is not available
47
+ * or if child product thumbnail is not available.
48
48
*/
49
- $ config = $ this ->scopeConfig ->getValue (
49
+ $ configValue = $ this ->scopeConfig ->getValue (
50
50
self ::CONFIG_THUMBNAIL_SOURCE ,
51
51
\Magento \Store \Model \ScopeInterface::SCOPE_STORE
52
52
);
53
53
$ childProduct = $ item ->getProduct ();
54
- $ childThumbnail = $ childProduct ->getData ('thumbnail ' );
54
+ $ childThumb = $ childProduct ->getData ('thumbnail ' );
55
55
56
56
$ finalProduct =
57
- ($ config == Thumbnail::OPTION_USE_PARENT_IMAGE ) || (!$ childThumbnail || $ childThumbnail == 'no_selection ' )
57
+ ($ configValue == Thumbnail::OPTION_USE_PARENT_IMAGE ) || (!$ childThumb || $ childThumb == 'no_selection ' )
58
58
? $ this ->getParentProduct ($ item )
59
59
: $ childProduct ;
60
60
return $ finalProduct ;
61
61
}
62
62
63
63
/**
64
- * Get grouped product
64
+ * Get grouped product.
65
65
*
66
66
* @param ItemInterface $item
67
67
* @return Product
Original file line number Diff line number Diff line change 3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
6
7
7
- /**
8
- * Wishlist block customer item cart column
9
- */
10
8
namespace Magento \Wishlist \Block \Customer \Wishlist \Item \Column ;
11
9
12
10
use Magento \Catalog \Model \Product \Image \UrlBuilder ;
15
13
use Magento \Catalog \Model \Product \Configuration \Item \ItemResolverInterface ;
16
14
17
15
/**
16
+ * Wishlist block customer item cart column
17
+ *
18
18
* @api
19
19
* @since 100.0.2
20
20
*/
@@ -54,7 +54,7 @@ public function __construct(
54
54
*
55
55
* @return \Magento\Catalog\Model\Product
56
56
*/
57
- public function getProductForThumbnail (\Magento \Wishlist \Model \Item $ item )
57
+ public function getProductForThumbnail (\Magento \Wishlist \Model \Item $ item ) : \ Magento \ Catalog \ Model \ Product
58
58
{
59
59
return $ this ->itemResolver ->getFinalProduct ($ item );
60
60
}
You can’t perform that action at this time.
0 commit comments