10
10
use Magento \Catalog \Api \Data \ProductInterface ;
11
11
use Magento \Catalog \Api \ProductLinkRepositoryInterface ;
12
12
use Magento \Catalog \Model \Product \Attribute \Backend \Media \EntryConverterPool ;
13
+ use Magento \Catalog \Model \Product \Attribute \Source \Status ;
13
14
use Magento \Catalog \Model \Product \Configuration \Item \Option \OptionInterface ;
14
15
use Magento \Framework \Api \AttributeValueFactory ;
15
16
use Magento \Framework \App \Filesystem \DirectoryList ;
@@ -202,7 +203,7 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
202
203
/**
203
204
* Catalog product status
204
205
*
205
- * @var \Magento\Catalog\Model\Product\Attribute\Source\ Status
206
+ * @var Status
206
207
*/
207
208
protected $ _catalogProductStatus ;
208
209
@@ -408,7 +409,7 @@ public function __construct(
408
409
\Magento \CatalogInventory \Api \Data \StockItemInterfaceFactory $ stockItemFactory ,
409
410
\Magento \Catalog \Model \Product \OptionFactory $ catalogProductOptionFactory ,
410
411
\Magento \Catalog \Model \Product \Visibility $ catalogProductVisibility ,
411
- \ Magento \ Catalog \ Model \ Product \ Attribute \ Source \ Status $ catalogProductStatus ,
412
+ Status $ catalogProductStatus ,
412
413
\Magento \Catalog \Model \Product \Media \Config $ catalogProductMediaConfig ,
413
414
Product \Type $ catalogProductType ,
414
415
\Magento \Framework \Module \Manager $ moduleManager ,
@@ -668,7 +669,7 @@ public function getTypeId()
668
669
public function getStatus ()
669
670
{
670
671
$ status = $ this ->_getData (self ::STATUS );
671
- return $ status !== null ? $ status : \ Magento \ Catalog \ Model \ Product \ Attribute \ Source \ Status::STATUS_ENABLED ;
672
+ return $ status !== null ? $ status : Status::STATUS_ENABLED ;
672
673
}
673
674
674
675
/**
@@ -1103,7 +1104,7 @@ public function afterDeleteCommit()
1103
1104
protected function _afterLoad ()
1104
1105
{
1105
1106
if (!$ this ->hasData (self ::STATUS )) {
1106
- $ this ->setData (self ::STATUS , \ Magento \ Catalog \ Model \ Product \ Attribute \ Source \ Status::STATUS_ENABLED );
1107
+ $ this ->setData (self ::STATUS , Status::STATUS_ENABLED );
1107
1108
}
1108
1109
parent ::_afterLoad ();
1109
1110
return $ this ;
@@ -1780,7 +1781,7 @@ public function isSaleable()
1780
1781
*/
1781
1782
public function isInStock ()
1782
1783
{
1783
- return $ this ->getStatus () == \ Magento \ Catalog \ Model \ Product \ Attribute \ Source \ Status::STATUS_ENABLED ;
1784
+ return $ this ->getStatus () == Status::STATUS_ENABLED ;
1784
1785
}
1785
1786
1786
1787
/**
@@ -2341,7 +2342,7 @@ public function getProductEntitiesInfo($columns = null)
2341
2342
*/
2342
2343
public function isDisabled ()
2343
2344
{
2344
- return $ this ->getStatus () == \ Magento \ Catalog \ Model \ Product \ Attribute \ Source \ Status::STATUS_DISABLED ;
2345
+ return $ this ->getStatus () == Status::STATUS_DISABLED ;
2345
2346
}
2346
2347
2347
2348
/**
@@ -2365,17 +2366,21 @@ public function getImage()
2365
2366
public function getIdentities ()
2366
2367
{
2367
2368
$ identities = [self ::CACHE_TAG . '_ ' . $ this ->getId ()];
2368
- if ($ this ->getIsChangedCategories ()) {
2369
- foreach ($ this ->getAffectedCategoryIds () as $ categoryId ) {
2370
- $ identities [] = self ::CACHE_PRODUCT_CATEGORY_TAG . '_ ' . $ categoryId ;
2369
+
2370
+ if (!$ this ->isObjectNew () || $ this ->getStatus () == Status::STATUS_ENABLED ) {
2371
+ if ($ this ->getIsChangedCategories ()) {
2372
+ foreach ($ this ->getAffectedCategoryIds () as $ categoryId ) {
2373
+ $ identities [] = self ::CACHE_PRODUCT_CATEGORY_TAG . '_ ' . $ categoryId ;
2374
+ }
2371
2375
}
2372
- }
2373
2376
2374
- if (($ this ->getOrigData ('status ' ) != $ this ->getData ('status ' )) || $ this ->isStockStatusChanged ()) {
2375
- foreach ($ this ->getCategoryIds () as $ categoryId ) {
2376
- $ identities [] = self ::CACHE_PRODUCT_CATEGORY_TAG . '_ ' . $ categoryId ;
2377
+ if (($ this ->getOrigData ('status ' ) != $ this ->getData ('status ' )) || $ this ->isStockStatusChanged ()) {
2378
+ foreach ($ this ->getCategoryIds () as $ categoryId ) {
2379
+ $ identities [] = self ::CACHE_PRODUCT_CATEGORY_TAG . '_ ' . $ categoryId ;
2380
+ }
2377
2381
}
2378
2382
}
2383
+
2379
2384
if ($ this ->_appState ->getAreaCode () == \Magento \Framework \App \Area::AREA_FRONTEND ) {
2380
2385
$ identities [] = self ::CACHE_TAG ;
2381
2386
}
0 commit comments