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
84a0ff77
Commit
84a0ff77
authored
Feb 24, 2023
by
wd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分类列表页添加商品图片列
parent
afe1e2a1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
0 deletions
+49
-0
app/code/Joshine/Category/Block/Adminhtml/Category/Tab/Product.php
+25
-0
app/code/Joshine/Category/Block/Adminhtml/Helper/Form/Image.php
+23
-0
app/code/Joshine/Category/etc/adminhtml/di.xml
+1
-0
No files found.
app/code/Joshine/Category/Block/Adminhtml/Category/Tab/Product.php
0 → 100644
View file @
84a0ff77
<?php
namespace
Joshine\Category\Block\Adminhtml\Category\Tab
;
use
Magento\Catalog\Block\Adminhtml\Category\Tab\Product
as
JoshineProduct
;
class
Product
extends
JoshineProduct
{
public
function
setCollection
(
$collection
){
echo
111
;
$collection
->
addAttributeToSelect
(
'thumbnail'
);
parent
::
setCollection
(
$collection
);
}
protected
function
_prepareColumns
(){
parent
::
_prepareColumns
();
$this
->
addColumnAfter
(
'image'
,
array
(
'header'
=>
__
(
'image'
),
'index'
=>
'thumbnail'
,
'renderer'
=>
'Joshine\Category\Block\Adminhtml\Helper\Form\Image'
),
'sku'
);
$this
->
sortColumnsByOrder
();
return
$this
;
}
}
\ No newline at end of file
app/code/Joshine/Category/Block/Adminhtml/Helper/Form/Image.php
0 → 100644
View file @
84a0ff77
<?php
namespace
Joshine\Category\Block\Adminhtml\Helper\Form
;
use
Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer
;
use
Magento\Framework\DataObject
;
class
image
extends
AbstractRenderer
{
public
function
render
(
DataObject
$row
)
{
$objectManager
=
\Magento\Framework\App\ObjectManager
::
getInstance
();
$helperImport
=
$objectManager
->
get
(
'\Magento\Catalog\Helper\Image'
);
$imageUrl
=
$helperImport
->
init
(
$row
,
'thumbnail'
)
->
setImageFile
(
$row
->
getData
(
'thumbnail'
))
// image,small_image,thumbnail
->
resize
(
380
)
->
getUrl
();
if
(
empty
(
$row
->
getData
(
'thumbnail'
))
){
return
"<span> No pictures </span>"
;
}
return
"<img src="
.
$imageUrl
.
" width='100' >"
;
}
}
\ No newline at end of file
app/code/Joshine/Category/etc/adminhtml/di.xml
View file @
84a0ff77
<?xml version="1.0"?>
<?xml version="1.0"?>
<config
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:framework:ObjectManager/etc/config.xsd"
>
<config
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation=
"urn:magento:framework:ObjectManager/etc/config.xsd"
>
<preference
for=
"Magento\Catalog\Block\Adminhtml\Category\Tab\Product"
type=
"Joshine\Category\Block\Adminhtml\Category\Tab\Product"
/>
<type
name=
"Joshine\Category\Controller\Adminhtml\Category\Image\Upload"
>
<type
name=
"Joshine\Category\Controller\Adminhtml\Category\Image\Upload"
>
<arguments>
<arguments>
<argument
name=
"imageUploader"
xsi:type=
"object"
>
Magento\Catalog\CategoryImageUpload
</argument>
<argument
name=
"imageUploader"
xsi:type=
"object"
>
Magento\Catalog\CategoryImageUpload
</argument>
...
...
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