Skip to content

Commit

Permalink
Merge pull request #18 from nordcomputer/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
nordcomputer committed Jan 17, 2024
2 parents 4b7842e + d742020 commit 7b75879
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 77 deletions.
52 changes: 36 additions & 16 deletions Setup/InstallData.php → Setup/Patch/Data/CreateFilterStock.php
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,35 +1,39 @@
<?php
namespace Nordcomputer\Stockfilter\Setup;
namespace Nordcomputer\Stockfilter\Setup\Patch\Data;

use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\InstallDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;

class InstallData implements InstallDataInterface
class CreateFilterStock implements DataPatchInterface
{
/** @var ModuleDataSetupInterface */
private $moduleDataSetup;

/** @var EavSetupFactory */
private $eavSetupFactory;

/**
*
* @param Magento\Eav\Setup\EavSetupFactory $eavSetupFactory
* @param ModuleDataSetupInterface $moduleDataSetup
* @param EavSetupFactory $eavSetupFactory
*/

public function __construct(EavSetupFactory $eavSetupFactory)
{
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
EavSetupFactory $eavSetupFactory
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->eavSetupFactory = $eavSetupFactory;
}

/**
* Installs filter_stock attribute
*
* @param ModuleDataSetupInterface $setup
* @param ModuleContextInterface $context
* @inheritdoc
*/
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
public function apply()
{
$eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
$eavSetup->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'filter_stock');
/** @var EavSetup $eavSetup */

$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);

$eavSetup->addAttribute(
\Magento\Catalog\Model\Product::ENTITY,
Expand Down Expand Up @@ -58,4 +62,20 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface
]
);
}

/**
* @inheritdoc
*/
public static function getDependencies()
{
return [];
}

/**
* @inheritdoc
*/
public function getAliases()
{
return [];
}
}
18 changes: 18 additions & 0 deletions Setup/Uninstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,31 @@

class Uninstall implements UninstallInterface
{
/** @var EavSetupFactory */
private $eavSetupFactory;

/**
* Method __construct
*
* @param EavSetupFactory $eavSetupFactory
*
* @return void
*/

public function __construct(EavSetupFactory $eavSetupFactory)
{
$this->eavSetupFactory = $eavSetupFactory;
}

/**
* Method uninstall
*
* @param SchemaSetupInterface $setup
* @param ModuleContextInterface $context
*
* @return void
*/

public function uninstall(SchemaSetupInterface $setup, ModuleContextInterface $context)
{
$setup->startSetup();
Expand Down
60 changes: 0 additions & 60 deletions Setup/UpgradeData.php

This file was deleted.

2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Nordcomputer_Stockfilter" setup_version="1.1"/>
<module name="Nordcomputer_Stockfilter" setup_version="1.2"/>
</config>

0 comments on commit 7b75879

Please sign in to comment.