Skip to content

Commit 68ec868

Browse files
cieslixtmotyl
authored andcommitted
[FIX] fix problem with navigation in catalog view (#24)
* [FIX] fix problem with navigation in catalog view
1 parent 73e546e commit 68ec868

File tree

2 files changed

+79
-13
lines changed

2 files changed

+79
-13
lines changed

Setup/Patch/Data/ImageRoles.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
namespace Macopedia\Allegro\Setup\Patch\Data;
44

5-
use Magento\Framework\Setup\Patch\DataPatchInterface;
6-
use Magento\Framework\Setup\Patch\PatchInterface;
5+
use Magento\Catalog\Model\Product\Attribute\Frontend\Image;
6+
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
77
use Magento\Eav\Setup\EavSetup;
88
use Magento\Eav\Setup\EavSetupFactory;
99
use Magento\Framework\Setup\ModuleDataSetupInterface;
10+
use Magento\Framework\Setup\Patch\DataPatchInterface;
1011

1112
/**
1213
* Image role patch script
1314
*/
1415
class ImageRoles implements DataPatchInterface
1516
{
16-
/** @var EavSetupFactory */
17+
/** @var EavSetupFactory */
1718
private $eavSetupFactory;
1819

19-
/** @var ModuleDataSetupInterface */
20+
/** @var ModuleDataSetupInterface */
2021
private $moduleDataSetup;
2122

2223
/**
@@ -60,16 +61,14 @@ public function apply()
6061
\Magento\Catalog\Model\Product::ENTITY,
6162
'allegro_image',
6263
[
63-
'type' => 'varchar',
64-
'label' => 'Allegro',
65-
'input' => 'media_image',
66-
'frontend' => 'Magento\Catalog\Model\Product\Attribute\Frontend\Image',
67-
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
68-
'filterable' => true,
69-
'visible_on_front' => false,
64+
'type' => 'varchar',
65+
'label' => 'Allegro Image',
66+
'input' => 'media_image',
67+
'frontend' => Image::class,
68+
'required' => false,
69+
'sort_order' => 5,
70+
'global' => ScopedAttributeInterface::SCOPE_STORE,
7071
'used_in_product_listing' => true,
71-
'sort_order' => 10,
72-
'required' => false,
7372
]
7473
);
7574
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
namespace Macopedia\Allegro\Setup\Patch\Data;
4+
5+
use Magento\Eav\Setup\EavSetup;
6+
use Magento\Eav\Setup\EavSetupFactory;
7+
use Magento\Framework\Setup\ModuleDataSetupInterface;
8+
use Magento\Framework\Setup\Patch\DataPatchInterface;
9+
10+
/**
11+
* Image role patch script
12+
*/
13+
class ImageRolesNotFilterable implements DataPatchInterface
14+
{
15+
/** @var EavSetupFactory */
16+
private $eavSetupFactory;
17+
18+
/** @var ModuleDataSetupInterface */
19+
private $moduleDataSetup;
20+
21+
/**
22+
* ImageRoles constructor.
23+
* @param EavSetupFactory $eavSetupFactory
24+
* @param ModuleDataSetupInterface $moduleDataSetup
25+
*/
26+
public function __construct(
27+
EavSetupFactory $eavSetupFactory,
28+
ModuleDataSetupInterface $moduleDataSetup
29+
) {
30+
$this->moduleDataSetup = $moduleDataSetup;
31+
$this->eavSetupFactory = $eavSetupFactory;
32+
}
33+
34+
/**
35+
* @return array|string[]
36+
*/
37+
public static function getDependencies()
38+
{
39+
return [
40+
ImageRoles::class
41+
];
42+
}
43+
44+
/**
45+
* @return array|string[]
46+
*/
47+
public function getAliases()
48+
{
49+
return [];
50+
}
51+
52+
/**
53+
* @return DataPatchInterface|void
54+
*/
55+
public function apply()
56+
{
57+
/** @var EavSetup $eavSetup */
58+
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
59+
60+
$eavSetup->updateAttribute(
61+
\Magento\Catalog\Model\Product::ENTITY,
62+
'allegro_image',
63+
'is_filterable',
64+
0
65+
);
66+
}
67+
}

0 commit comments

Comments
 (0)