Skip to content

Commit

Permalink
askit migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tangar76 committed Jul 10, 2017
1 parent 06d0179 commit 50680ff
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Handler/AskIt/NullToZero.php
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');
}
}
}
74 changes: 74 additions & 0 deletions tip/ask-it.md
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>
~~~

0 comments on commit 50680ff

Please sign in to comment.