File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 33namespace Yireo \GoogleTagManager2 \DataLayer \Tag \Category ;
44
55use Magento \Framework \Exception \NoSuchEntityException ;
6+ use Magento \Catalog \Model \Category ;
67use Yireo \GoogleTagManager2 \Config \Config ;
78use Yireo \GoogleTagManager2 \Api \Data \TagInterface ;
89use Yireo \GoogleTagManager2 \Util \GetCurrentCategory ;
@@ -40,14 +41,19 @@ public function __construct(
4041 */
4142 public function get (): array
4243 {
44+ $ category = $ this ->getCurrentCategory ->get ();
45+ if ($ category ->getDisplayMode () === Category::DM_PAGE ) {
46+ return [];
47+ }
48+
4349 $ productsData = [];
4450 $ i = 1 ;
4551 foreach ($ this ->getCurrentCategoryProducts ->getProducts () as $ product ) {
4652 if ($ this ->config ->getMaximumCategoryProducts () > 0 && $ i > $ this ->config ->getMaximumCategoryProducts ()) {
4753 break ;
4854 }
4955
50- $ product ->setCategory ($ this -> getCurrentCategory -> get () );
56+ $ product ->setCategory ($ product );
5157 $ productData = $ this ->productDataMapper ->mapByProduct ($ product );
5258 $ productData ['quantity ' ] = 1 ;
5359 $ productData ['index ' ] = $ i ;
You can’t perform that action at this time.
0 commit comments