Skip to content

Commit 2253bd9

Browse files
author
Leonid Poluyanov
committed
Merge remote-tracking branch 'origin/MAGETWO-37944' into MAGETWO-37985
2 parents a3ff3c6 + a38ae73 commit 2253bd9

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Setup;
7+
8+
use Magento\Framework\Setup\UpgradeDataInterface;
9+
use Magento\Framework\Setup\ModuleContextInterface;
10+
use Magento\Framework\Setup\ModuleDataSetupInterface;
11+
use Magento\Catalog\Model\Category;
12+
13+
/**
14+
* @codeCoverageIgnore
15+
*/
16+
class UpgradeData implements UpgradeDataInterface
17+
{
18+
/**
19+
* @var Category
20+
*/
21+
protected $category;
22+
23+
/**
24+
* @param Category $category
25+
*/
26+
public function __construct(Category $category)
27+
{
28+
$this->category = $category;
29+
}
30+
31+
/**
32+
* {@inheritdoc}
33+
*/
34+
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
35+
{
36+
if (version_compare($context->getVersion(), '2.0.0.2') < 0) {
37+
$newBackendModel = 'Magento\Catalog\Model\Attribute\Backend\Startdate';
38+
$connection = $setup->getConnection();
39+
$connection->startSetup();
40+
$connection->update(
41+
$setup->getTable('eav_attribute'),
42+
['backend_model' => $newBackendModel],
43+
['backend_model = ?' => 'Magento\Catalog\Model\Product\Attribute\Backend\Startdate']
44+
);
45+
/** @var \Magento\Catalog\Model\Resource\Eav\Attribute $attribute */
46+
foreach($this->category->getAttributes() as $attribute) {
47+
if ($attribute->getAttributeCode() == 'custom_design_from') {
48+
$attribute->setBackendModel($newBackendModel);
49+
$attribute->save();
50+
break;
51+
}
52+
}
53+
$connection->endSetup();
54+
}
55+
}
56+
}

app/code/Magento/Catalog/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
9-
<module name="Magento_Catalog" setup_version="2.0.0.1">
9+
<module name="Magento_Catalog" setup_version="2.0.0.2">
1010
<sequence>
1111
<module name="Magento_Eav"/>
1212
<module name="Magento_Cms"/>

0 commit comments

Comments
 (0)