Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
joshine
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
joshine
Commits
3aa91326
Commit
3aa91326
authored
Apr 25, 2023
by
halweg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
a4d666a8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
app/code/Joshine/Script/Console/Command/ReviewsImporter.php
+11
-15
No files found.
app/code/Joshine/Script/Console/Command/ReviewsImporter.php
View file @
3aa91326
...
...
@@ -14,6 +14,7 @@ use Magento\Framework\Exception\NoSuchEntityException;
use
Magento\Framework\File\Csv
;
use
Magento\Framework\ObjectManager\ObjectManager
;
use
Magento\Setup\Exception
;
use
Magento\Store\Model\App\Emulation
;
use
Symfony\Component\Console\Command\Command
;
use
Symfony\Component\Console\Input\InputInterface
;
use
Symfony\Component\Console\Input\InputOption
;
...
...
@@ -166,12 +167,12 @@ class ReviewsImporter extends Command
return
;
}
$store
I
d
=
$input
->
getOption
(
'store_id'
);
if
(
!
$store
I
d
)
{
$store
_i
d
=
$input
->
getOption
(
'store_id'
);
if
(
!
$store
_i
d
)
{
$output
->
writeln
(
$this
->
errorWrapper
(
"store_id没填"
));
return
;
}
$this
->
storeId
=
$store
I
d
;
$this
->
storeId
=
$store
_i
d
;
$this
->
importCsvFile
(
$path
);
}
catch
(
\Exception
$e
)
{
$output
->
writeln
(
$this
->
errorWrapper
(
$e
->
getMessage
()));
...
...
@@ -192,6 +193,7 @@ class ReviewsImporter extends Command
private
function
insertDB
(
$data
)
{
$objectManager
=
\Magento\Framework\App\ObjectManager
::
getInstance
();
$reviewFactory
=
$objectManager
->
get
(
"Magento\Review\Model\ReviewFactory"
);
$ratingFactory
=
$objectManager
->
get
(
"Magento\Review\Model\RatingFactory"
);
...
...
@@ -319,21 +321,15 @@ class ReviewsImporter extends Command
$review
[
'size_fits'
]
=
trim
(
$row
[
6
]);
$review
[
'date'
]
=
trim
(
$row
[
7
]);
if
(
empty
(
trim
(
$review
[
"sku"
]))
||
empty
(
trim
(
$review
[
"detail"
])
||
empty
(
trim
(
$review
[
"detail"
])
)
||
empty
(
trim
(
$review
[
'nickname'
]))
||
empty
(
$review
[
'date'
])
||
empty
(
$review
[
'title'
])
)
||
empty
(
$review
[
'title'
]
||
empty
(
$review
[
'size_fits'
])
||
empty
(
$review
[
'ratings'
])
)
)
{
throw
new
\Exception
(
"表格数据有空:
{
$row
[
"name"
]
}
"
);
}
if
(
!
is_integer
(
$review
[
'size_fits'
]))
{
$review
[
'size_fits'
]
=
3
;
}
if
(
!
is_integer
(
$review
[
'ratings'
]))
{
$review
[
'ratings'
]
=
5
;
throw
new
\Exception
(
"表格数据有空!"
);
}
$data
[]
=
$review
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment