5
5
*/
6
6
namespace Magento \Catalog \Console \Command ;
7
7
8
+ use Magento \Catalog \Api \ProductRepositoryInterface ;
9
+ use Magento \Catalog \Model \Product \Image \CacheFactory ;
10
+ use Magento \Catalog \Model \ResourceModel \Product \CollectionFactory ;
8
11
use Magento \Catalog \Model \ResourceModel \Product \Image as ProductImage ;
9
12
use Magento \Framework \App \Area ;
13
+ use Magento \Framework \App \ObjectManager ;
10
14
use Magento \Framework \App \State ;
11
15
use Magento \Catalog \Helper \Image as ImageHelper ;
12
16
use Magento \Framework \Console \Cli ;
@@ -27,7 +31,25 @@ class ImagesResizeCommand extends Command
27
31
/**
28
32
* @var State
29
33
*/
30
- private $ appState ;
34
+ protected $ appState ;
35
+
36
+ /**
37
+ * @deprecated
38
+ * @var CollectionFactory
39
+ */
40
+ protected $ productCollectionFactory ;
41
+
42
+ /**
43
+ * @deprecated
44
+ * @var ProductRepositoryInterface
45
+ */
46
+ protected $ productRepository ;
47
+
48
+ /**
49
+ * @deprecated
50
+ * @var CacheFactory
51
+ */
52
+ protected $ imageCacheFactory ;
31
53
32
54
/**
33
55
* @var ProductImage
@@ -51,23 +73,33 @@ class ImagesResizeCommand extends Command
51
73
52
74
/**
53
75
* @param State $appState
76
+ * @param CollectionFactory $productCollectionFactory
77
+ * @param ProductRepositoryInterface $productRepository
78
+ * @param CacheFactory $imageCacheFactory
54
79
* @param ProductImage $productImage
55
80
* @param ViewConfig $viewConfig
56
81
* @param ThemeCollection $themeCollection
57
82
* @param ProductImageFactory $productImageFactory
58
83
*/
59
84
public function __construct (
60
85
State $ appState ,
61
- ProductImage $ productImage ,
62
- ViewConfig $ viewConfig ,
63
- ThemeCollection $ themeCollection ,
64
- ProductImageFactory $ productImageFactory
86
+ CollectionFactory $ productCollectionFactory ,
87
+ ProductRepositoryInterface $ productRepository ,
88
+ CacheFactory $ imageCacheFactory ,
89
+ ProductImage $ productImage = null ,
90
+ ViewConfig $ viewConfig = null ,
91
+ ThemeCollection $ themeCollection = null ,
92
+ ProductImageFactory $ productImageFactory = null
65
93
) {
66
94
$ this ->appState = $ appState ;
67
- $ this ->productImage = $ productImage ;
68
- $ this ->viewConfig = $ viewConfig ;
69
- $ this ->themeCollection = $ themeCollection ;
70
- $ this ->productImageFactory = $ productImageFactory ;
95
+ $ this ->productCollectionFactory = $ productCollectionFactory ;
96
+ $ this ->productRepository = $ productRepository ;
97
+ $ this ->imageCacheFactory = $ imageCacheFactory ;
98
+ $ this ->productImage = $ productImage ?: ObjectManager::getInstance ()->get (ProductImage::class);
99
+ $ this ->viewConfig = $ viewConfig ?: ObjectManager::getInstance ()->get (ViewConfig::class);
100
+ $ this ->themeCollection = $ themeCollection ?: ObjectManager::getInstance ()->get (ThemeCollection::class);
101
+ $ this ->productImageFactory = $ productImageFactory
102
+ ?: ObjectManager::getInstance ()->get (ProductImageFactory::class);
71
103
parent ::__construct ();
72
104
}
73
105
0 commit comments