File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Algolia \AlgoliaSearch \Model \Observer \Product ;
4
+
5
+ use Algolia \AlgoliaSearch \Model \Cache \Product \IndexCollectionSize as Cache ;
6
+ use Magento \Framework \Event \ObserverInterface ;
7
+ use Magento \Framework \Event \Observer ;
8
+
9
+ /**
10
+ * Handle the `catalog_product_attribute_update_before` event.
11
+ * Triggered via mass action "Change status" but not "Update attributes"
12
+ */
13
+ class CacheCleanAttributeUpdate implements ObserverInterface
14
+ {
15
+ public function __construct (
16
+ protected readonly Cache $ cache
17
+ ) {}
18
+
19
+ public function execute (Observer $ observer ): void
20
+ {
21
+ $ attributes = $ observer ->getData ('attributes_data ' );
22
+ $ productIds = $ observer ->getData ('product_ids ' );
23
+ $ attributesToObserve = ['status ' ];
24
+
25
+ if ($ productIds
26
+ && array_intersect (array_keys ($ attributes ), $ attributesToObserve )) {
27
+ $ this ->cache ->clear ();
28
+ }
29
+ }
30
+ }
31
+
32
+
33
+
34
+
Original file line number Diff line number Diff line change 4
4
<observer name =" algoliasearch_reindex_product_on_last_item_purchase_if_msi_disable"
5
5
instance =" Algolia\AlgoliaSearch\Observer\ReindexProductOnLastItemPurchaseIfMsiDisable" />
6
6
</event >
7
+
8
+ <event name =" catalog_product_attribute_update_before" >
9
+ <observer name =" clean_cache_on_mass_product_before" instance =" Algolia\AlgoliaSearch\Model\Observer\Product\CacheCleanAttributeUpdate" />
10
+ </event >
11
+
7
12
</config >
You can’t perform that action at this time.
0 commit comments