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
84ad8771
Commit
84ad8771
authored
Apr 07, 2023
by
halweg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix : change base img break when last image
parent
8f5d7685
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
app/code/Joshine/Script/Console/Command/ProductFirstImageAsBaseFixer.php
+6
-0
app/code/Joshine/Script/Model/ImageQueryResource.php
+20
-0
No files found.
app/code/Joshine/Script/Console/Command/ProductFirstImageAsBaseFixer.php
View file @
84ad8771
...
...
@@ -65,6 +65,12 @@ class ProductFirstImageAsBaseFixer extends Command
return
;
}
$lastImage
=
$this
->
imageQueryResource
->
getLastImage
(
$productId
);
if
(
$mainImage
!=
$lastImage
)
{
$output
->
writeln
(
'base image not last, break'
);
return
;
}
if
(
$mainImage
!=
$firstImage
)
{
$output
->
writeln
(
'fix product '
.
$mainImage
.
' product id: '
.
$productId
);
//change main image
...
...
app/code/Joshine/Script/Model/ImageQueryResource.php
View file @
84ad8771
...
...
@@ -109,4 +109,23 @@ class ImageQueryResource
);
}
public
function
getLastImage
(
$productId
)
{
$select
=
$this
->
resourceConnection
->
getConnection
()
->
select
();
$select
->
from
([
'v'
=>
$this
->
resourceConnection
->
getTableName
(
'catalog_product_entity_media_gallery_value'
)]);
$select
->
join
(
[
'g'
=>
'catalog_product_entity_media_gallery'
],
'g.value_id=v.value_id'
,
[]
);
$select
->
where
(
'entity_id=?'
,
$productId
);
$select
->
reset
(
\Magento\Framework\DB\Select
::
COLUMNS
);
$select
->
columns
([
'g.value'
,
'v.position'
]);
$select
->
order
(
'v.position DESC'
);
$select
->
limit
(
1
);
return
$this
->
resourceConnection
->
getConnection
()
->
fetchOne
(
$select
);
}
}
\ No newline at end of file
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