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
cd0bbfc7
Commit
cd0bbfc7
authored
Mar 23, 2023
by
dhn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
国家置顶
parent
c7cc5664
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
0 deletions
+51
-0
app/code/Magento/Backend/etc/adminhtml/system.xml
+8
-0
app/code/Magento/Directory/Model/ResourceModel/Country/CollectionNew.php
+40
-0
app/code/Magento/Directory/etc/di.xml
+3
-0
No files found.
app/code/Magento/Backend/etc/adminhtml/system.xml
View file @
cd0bbfc7
...
...
@@ -363,6 +363,14 @@
</depends>
</field>
</group>
<group
id=
"top_country"
translate=
"label"
type=
"text"
sortOrder=
"1"
showInDefault=
"1"
showInWebsite=
"1"
showInStore=
"1"
>
<label>
Top Country
</label>
<field
id=
"top_countrys"
translate=
"label"
type=
"text"
sortOrder=
"10"
showInDefault=
"1"
>
<label>
置顶国家
</label>
<comment>
国家简码为2个大写字母,多个用英文逗号隔开.
</comment>
</field>
</group>
</section>
<section
id=
"admin"
translate=
"label"
type=
"text"
sortOrder=
"20"
showInDefault=
"1"
>
<label>
Admin
</label>
...
...
app/code/Magento/Directory/Model/ResourceModel/Country/CollectionNew.php
0 → 100644
View file @
cd0bbfc7
<?php
namespace
Magento\Directory\Model\ResourceModel\Country
;
class
CollectionNew
{
protected
$scopeConfig
;
public
function
__construct
(
\Magento\Framework\App\Config\ScopeConfigInterface
$scopeConfig
)
{
$this
->
scopeConfig
=
$scopeConfig
;
}
public
function
afterToOptionArray
(
\Magento\Directory\Model\ResourceModel\Country\Collection
$subject
,
$result
)
{
if
(
!
is_array
(
$result
)
||
empty
(
$result
))
{
return
$result
;
}
$topCountry
=
$this
->
scopeConfig
->
getValue
(
'system/top_country/top_countrys'
);
if
(
!
$topCountry
)
{
return
$result
;
}
if
(
!
$result
[
0
][
'value'
])
{
unset
(
$result
[
0
]);
}
$topCountry
=
explode
(
','
,
$topCountry
);
$indexs
=
array_flip
(
$topCountry
);
$top
=
[];
$top
[
0
]
=
[
'value'
=>
''
,
'label'
=>
''
];
foreach
(
$result
as
$row
)
{
if
(
in_array
(
$row
[
'value'
],
$topCountry
))
{
$idx
=
$indexs
[
$row
[
'value'
]]
+
1
;
$top
[
$idx
]
=
$row
;
}
}
ksort
(
$top
);
$top
[]
=
[
'value'
=>
'-'
,
'label'
=>
'---'
];
$result
=
array_merge
(
$top
,
$result
);
return
$result
;
}
}
\ No newline at end of file
app/code/Magento/Directory/etc/di.xml
View file @
cd0bbfc7
...
...
@@ -39,6 +39,9 @@
</argument>
</arguments>
</type>
<type
name=
"Magento\Directory\Model\ResourceModel\Country\Collection"
>
<plugin
name=
"new_country_collection"
type=
"Magento\Directory\Model\ResourceModel\Country\CollectionNew"
/>
</type>
<preference
for=
"Magento\Directory\Model\Country\Postcode\ConfigInterface"
type=
"Magento\Directory\Model\Country\Postcode\Config"
/>
<preference
for=
"Magento\Directory\Model\Country\Postcode\ValidatorInterface"
type=
"Magento\Directory\Model\Country\Postcode\Validator"
/>
<preference
for=
"Magento\Directory\Api\CurrencyInformationAcquirerInterface"
type=
"Magento\Directory\Model\CurrencyInformationAcquirer"
/>
...
...
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