-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
103 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
namespace Swissup\DataMigration\Handler\AskIt; | ||
|
||
use Migration\Handler\AbstractHandler; | ||
use Migration\Handler\HandlerInterface; | ||
use Migration\ResourceModel\Record; | ||
|
||
/** | ||
* Handler to set constant value to the field | ||
*/ | ||
class NullToZero extends AbstractHandler implements HandlerInterface | ||
{ | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function handle(Record $recordToHandle, Record $oppositeRecord) | ||
{ | ||
$this->validate($recordToHandle); | ||
$value = $recordToHandle->getValue($this->field); | ||
if ($value === NULL) { | ||
$recordToHandle->setValue($this->field, '0'); | ||
} | ||
} | ||
} |
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,74 @@ | ||
Add to *map.xml*: | ||
|
||
~~~xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<map xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="../../map.xsd"> | ||
<source> | ||
<document_rules> | ||
... | ||
... | ||
... | ||
<!-- rename table in M1 as it is in M2 --> | ||
<rename> | ||
<document>tm_askit_item</document> | ||
<to>swissup_askit_item</to> | ||
</rename> | ||
<rename> | ||
<document>tm_askit_message</document> | ||
<to>swissup_askit_message</to> | ||
</rename> | ||
<rename> | ||
<document>tm_askit_vote</document> | ||
<to>swissup_askit_vote</to> | ||
</rename> | ||
... | ||
... | ||
... | ||
</document_rules> | ||
<field_rules> | ||
... | ||
... | ||
... | ||
<!-- map and ignore datatype mismatch from M1 --> | ||
<move> | ||
<field>tm_askit_message.private</field> | ||
<to>swissup_askit_message.is_private</to> | ||
</move> | ||
<ignore> | ||
<datatype>tm_askit_message.created_time</datatype> | ||
</ignore> | ||
<ignore> | ||
<datatype>tm_askit_message.update_time</datatype> | ||
</ignore> | ||
... | ||
... | ||
... | ||
</field_rules> | ||
</source> | ||
<destination> | ||
<document_rules> | ||
... | ||
... | ||
... | ||
</document_rules> | ||
<field_rules> | ||
... | ||
... | ||
... | ||
<transform> | ||
<field>swissup_askit_message.parent_id</field> | ||
<handler class="\Swissup\DataMigration\Handler\AskIt\NullToZero" /> | ||
</transform> | ||
<ignore> | ||
<datatype>swissup_askit_message.created_time</datatype> | ||
</ignore> | ||
<ignore> | ||
<datatype>swissup_askit_message.update_time</datatype> | ||
</ignore> | ||
... | ||
... | ||
... | ||
</field_rules> | ||
</destination> | ||
</map> | ||
~~~ |