-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from mageplaza/2.4-develop
2.4 develop
- Loading branch information
Showing
5 changed files
with
199 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
<?php | ||
/** | ||
* Mageplaza | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Mageplaza.com license that is | ||
* available through the world-wide-web at this URL: | ||
* https://mageplaza.com/LICENSE.txt | ||
* | ||
* DISCLAIMER | ||
* | ||
* Do not edit or add to this file if you wish to upgrade this extension to newer | ||
* version in the future. | ||
* | ||
* @category Mageplaza | ||
* @package Mageplaza_Seo | ||
* @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) | ||
* @license http://mageplaza.com/LICENSE.txt | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mageplaza\Seo\Setup\Patch\Data; | ||
|
||
use Magento\Catalog\Model\Category; | ||
use Magento\Catalog\Model\Product; | ||
use Magento\Eav\Setup\EavSetupFactory; | ||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
use Magento\Framework\Setup\Patch\DataPatchInterface; | ||
|
||
/** | ||
* Patch is mechanism, that allows to do atomic upgrade data changes | ||
* Class RemoveAttribute | ||
* @package Mageplaza\Seo\Setup\Patch\Data | ||
*/ | ||
class RemoveAttribute implements DataPatchInterface | ||
{ | ||
/** | ||
* @var ModuleDataSetupInterface $moduleDataSetup | ||
*/ | ||
private $moduleDataSetup; | ||
|
||
/** | ||
* @var EavSetupFactory | ||
*/ | ||
private $eavSetupFactory; | ||
|
||
/** | ||
* @param ModuleDataSetupInterface $moduleDataSetup | ||
* @param EavSetupFactory $eavSetupFactory | ||
*/ | ||
public function __construct( | ||
ModuleDataSetupInterface $moduleDataSetup, | ||
EavSetupFactory $eavSetupFactory | ||
) { | ||
$this->moduleDataSetup = $moduleDataSetup; | ||
$this->eavSetupFactory = $eavSetupFactory; | ||
} | ||
|
||
/** | ||
* Do Upgrade | ||
* | ||
* @return void | ||
*/ | ||
public function apply() | ||
{ | ||
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); | ||
$this->removeAttribute($eavSetup, Product::ENTITY, 'mp_meta_robots'); | ||
$this->removeAttribute($eavSetup, Product::ENTITY, 'mp_seo_og_description'); | ||
$this->removeAttribute($eavSetup, Category::ENTITY, 'mp_meta_robots'); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getAliases() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public static function getDependencies() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public static function getVersion() | ||
{ | ||
return '2.0.1'; | ||
} | ||
|
||
|
||
/** | ||
* Remove attribute | ||
* | ||
* @param $eavSetup | ||
* @param $model | ||
* @param $id | ||
*/ | ||
private function removeAttribute($eavSetup, $model, $id) | ||
{ | ||
if ($eavSetup->getAttributeId($model, $id)) { | ||
$eavSetup->removeAttribute($model, $id); | ||
} | ||
} | ||
} |
Oops, something went wrong.