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
914312cd
Commit
914312cd
authored
Dec 01, 2022
by
lmf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
可能感兴趣的产品系统自动推荐
parent
32d4d3cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
1 deletions
+21
-1
app/code/Magento/Catalog/Block/Product/ProductList/Related.php
+1
-1
app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php
+20
-0
No files found.
app/code/Magento/Catalog/Block/Product/ProductList/Related.php
View file @
914312cd
...
...
@@ -117,7 +117,7 @@ class Related extends AbstractProduct implements IdentityInterface
$collection
->
addCategoriesFilter
([
'in'
=>
$product
->
getCategoryIds
()]);
$collection
->
setVisibility
(
$this
->
_catalogProductVisibility
->
getVisibleInCatalogIds
());
$collection
->
getSelect
()
->
order
(
'rand()'
);
$collection
->
setPageSize
(
6
);
$collection
->
setPageSize
(
10
);
$collection
->
addStoreFilter
(
$product
->
getStoreId
());
$this
->
_itemCollection
=
$collection
;
}
...
...
app/code/Magento/Catalog/Block/Product/ProductList/Upsell.php
View file @
914312cd
...
...
@@ -16,6 +16,7 @@ use Magento\Checkout\Model\Session as CheckoutSession;
use
Magento\Framework\DataObject
;
use
Magento\Framework\DataObject\IdentityInterface
;
use
Magento\Framework\Module\Manager
;
use
Magento\Reports\Model\ResourceModel\Product\CollectionFactory
;
/**
* Catalog product upsell items block
...
...
@@ -27,6 +28,11 @@ use Magento\Framework\Module\Manager;
class
Upsell
extends
AbstractProduct
implements
IdentityInterface
{
/**
* @var Collection
*/
protected
$_collectionFactory
;
/**
* @var int
*/
protected
$_columnCount
=
4
;
...
...
@@ -86,8 +92,10 @@ class Upsell extends AbstractProduct implements IdentityInterface
ProductVisibility
$catalogProductVisibility
,
CheckoutSession
$checkoutSession
,
Manager
$moduleManager
,
CollectionFactory
$collectionFactory
,
array
$data
=
[]
)
{
$this
->
_collectionFactory
=
$collectionFactory
;
$this
->
_checkoutCart
=
$checkoutCart
;
$this
->
_catalogProductVisibility
=
$catalogProductVisibility
;
$this
->
_checkoutSession
=
$checkoutSession
;
...
...
@@ -120,6 +128,18 @@ class Upsell extends AbstractProduct implements IdentityInterface
[
'product'
=>
$product
,
'collection'
=>
$this
->
_itemCollection
,
'limit'
=>
null
]
);
if
(
!
count
(
$this
->
_itemCollection
->
getItems
())){
$collection
=
$this
->
_collectionFactory
->
create
();
$collection
->
addAttributeToSelect
(
'*'
);
$collection
->
addCategoriesFilter
([
'not in'
=>
$product
->
getCategoryIds
()]);
$collection
->
setVisibility
(
$this
->
_catalogProductVisibility
->
getVisibleInCatalogIds
());
$collection
->
getSelect
()
->
order
(
'rand()'
);
$collection
->
setPageSize
(
10
);
$collection
->
addStoreFilter
(
$product
->
getStoreId
());
$this
->
_itemCollection
=
$collection
;
}
foreach
(
$this
->
_itemCollection
as
$product
)
{
$product
->
setDoNotUseCategoryId
(
true
);
}
...
...
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