Skip to content

Commit da41365

Browse files
committed
Improved Import
1 parent 935d381 commit da41365

File tree

4 files changed

+9
-40
lines changed

4 files changed

+9
-40
lines changed

Block/Adminhtml/Import/Aheadworks/Form.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ protected function _prepareForm()
7272
]
7373
);
7474

75-
$fieldset->addField(
76-
'notice',
77-
'label',
78-
[
79-
'label' => __('NOTICE'),
80-
'name' => 'prefix',
81-
'after_element_html' => 'When the import is completed successfully, please copy image files from AheadWorks <strong style="color:#bd1616;">aw-content/uploads</strong> directory to Magento <strong style="color:#105610;">pub/media/magefan_blog</strong> directory.',
82-
]
83-
);
84-
8575
$fieldset->addField(
8676
'dbname',
8777
'text',
@@ -115,7 +105,7 @@ protected function _prepareForm()
115105
'label' => __('Password'),
116106
'title' => __('Password'),
117107
'name' => 'pwd',
118-
'required' => true,
108+
'required' => false,
119109
'disabled' => $isElementDisabled,
120110
'after_element_html' => '<small>…and your AW MySQL password.</small>',
121111
]
@@ -141,7 +131,7 @@ protected function _prepareForm()
141131
'label' => __('Table Prefix'),
142132
'title' => __('Table Prefix'),
143133
'name' => 'prefix',
144-
'required' => true,
134+
'required' => false,
145135
'disabled' => $isElementDisabled,
146136
'after_element_html' => '<small>…and your AW MySQL table prefix.</small>',
147137
]
@@ -179,9 +169,11 @@ protected function _prepareForm()
179169

180170
$this->_eventManager->dispatch('magefan_blog_import_aheadworks_prepare_form', ['form' => $form]);
181171

172+
/*
182173
if (empty($data['prefix'])) {
183174
$data['prefix'] = 'aw_';
184175
}
176+
*/
185177

186178
if (empty($data['dbhost'])) {
187179
$data['dbhost'] = 'localhost';

Block/Adminhtml/Import/Wordpress/Form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ protected function _prepareForm()
119119
'label' => __('Password'),
120120
'title' => __('Password'),
121121
'name' => 'pwd',
122-
'required' => true,
122+
'required' => false,
123123
'disabled' => $isElementDisabled,
124124
'after_element_html' => '<small>…and your WP MySQL password.</small>',
125125
]
@@ -145,7 +145,7 @@ protected function _prepareForm()
145145
'label' => __('Table Prefix'),
146146
'title' => __('Table Prefix'),
147147
'name' => 'prefix',
148-
'required' => true,
148+
'required' => false,
149149
'disabled' => $isElementDisabled,
150150
'after_element_html' => '<small>…and your WP MySQL table prefix.</small>',
151151
]

Model/Import/Aw.php

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,10 @@
1515
*/
1616
class Aw extends AbstractImport
1717
{
18-
protected $_requiredFields = ['dbname', 'uname', 'pwd', 'dbhost', 'prefix'];
18+
protected $_requiredFields = ['dbname', 'uname', 'dbhost'];
1919

2020
public function execute()
2121
{
22-
$config = \Magento\Framework\App\ObjectManager::getInstance()
23-
->get('Magento\Framework\App\DeploymentConfig');
24-
$pref = ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT . '/';
25-
$this->setData(
26-
'dbhost',
27-
$config->get($pref . ConfigOptionsListConstants::KEY_HOST)
28-
)->setData(
29-
'uname',
30-
$config->get($pref . ConfigOptionsListConstants::KEY_USER)
31-
)->setData(
32-
'pwd',
33-
$config->get($pref . ConfigOptionsListConstants::KEY_PASSWORD)
34-
)->setData(
35-
'dbname',
36-
$config->get($pref . ConfigOptionsListConstants::KEY_NAME)
37-
);
38-
3922
$host = $this->getData('dbhost') ?: $this->getData('host');
4023
if (false !== strpos($host, '.sock')) {
4124
$con = $this->_connect = mysqli_connect(
@@ -59,10 +42,7 @@ public function execute()
5942
throw new \Exception("Failed connect to magento database", 1);
6043
}
6144

62-
$_pref = mysqli_real_escape_string(
63-
$con,
64-
$config->get($pref . ConfigOptionsListConstants::KEY_PREFIX)
65-
);
45+
$_pref = mysqli_real_escape_string($con, $this->getData('prefix'));
6646

6747
$sql = 'SELECT * FROM '.$_pref.'aw_blog_cat LIMIT 1';
6848
try {

Model/Import/Wordpress.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
class Wordpress extends AbstractImport
1515
{
16-
protected $_requiredFields = ['dbname', 'uname', 'pwd', 'dbhost', 'prefix'];
16+
protected $_requiredFields = ['dbname', 'uname', 'dbhost'];
1717

1818
public function execute()
1919
{
@@ -47,7 +47,6 @@ public function execute()
4747
while ($data = mysqli_fetch_assoc($result)) {
4848
/* Prepare category data */
4949
foreach (['title', 'identifier'] as $key) {
50-
/*$data[$key] = utf8_encode($data[$key]);*/
5150
$data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8');
5251
}
5352

@@ -123,7 +122,6 @@ public function execute()
123122
while ($data = mysqli_fetch_assoc($result)) {
124123
/* Prepare tag data */
125124
foreach (['title', 'identifier'] as $key) {
126-
/*$data[$key] = utf8_encode($data[$key]);*/
127125
$data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8');
128126
}
129127

@@ -217,7 +215,6 @@ public function execute()
217215

218216
/* Prepare post data */
219217
foreach (['post_title', 'post_name', 'post_content'] as $key) {
220-
/*$data[$key] = utf8_encode($data[$key]);*/
221218
$data[$key] = mb_convert_encoding($data[$key], 'HTML-ENTITIES', 'UTF-8');
222219
}
223220

0 commit comments

Comments
 (0)