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
fabbfc88
Commit
fabbfc88
authored
Mar 28, 2023
by
wd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改商品地址为主商品地址
parent
74d41df3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
app/code/Joshine/GoogleFeed/Console/Command/GoogleFeed.php
+21
-3
No files found.
app/code/Joshine/GoogleFeed/Console/Command/GoogleFeed.php
View file @
fabbfc88
...
...
@@ -20,6 +20,7 @@ use Magento\Catalog\Model\CategoryList;
use
Magento\Framework\App\Config\ScopeConfigInterface
;
use
Magento\Eav\Api\AttributeRepositoryInterface
;
use
Magento\Store\Model\Website
;
use
Magento\ConfigurableProduct\Model\Product\Type\Configurable
;
/**
* Class SomeCommand
*/
...
...
@@ -49,6 +50,8 @@ class GoogleFeed extends Command
private
$attributeRepositoryInterface
;
/* @var Website */
private
$webSite
;
/* @var Configurable */
private
$configurable
;
/*table title*/
private
$columns
=
array
(
'id'
,
...
...
@@ -146,7 +149,8 @@ class GoogleFeed extends Command
CategoryList
$categoryList
,
ScopeConfigInterface
$scopeConfigInterface
,
AttributeRepositoryInterface
$attributeRepositoryInterface
,
Website
$webSite
Website
$webSite
,
Configurable
$configurable
)
{
$this
->
state
=
$state
;
...
...
@@ -162,6 +166,7 @@ class GoogleFeed extends Command
$this
->
scopeConfigInterface
=
$scopeConfigInterface
;
$this
->
attributeRepositoryInterface
=
$attributeRepositoryInterface
;
$this
->
webSite
=
$webSite
;
$this
->
configurable
=
$configurable
;
parent
::
__construct
();
}
...
...
@@ -271,8 +276,8 @@ class GoogleFeed extends Command
$data
[
'google product category'
]
=
$categoryGoogleProductCategory
[
$categoryId
][
'GoogleProductCategory'
];
$data
[
'product type'
]
=
$categoryGoogleProductCategory
[
$categoryId
][
'product type'
];
$data
[
'link'
]
=
$
product
->
getProductUrl
(
);
$data
[
'mobile link'
]
=
$
product
->
getProductUrl
()
;
$data
[
'link'
]
=
$
this
->
getConfigProductUrl
(
$product
);
$data
[
'mobile link'
]
=
$
data
[
'link'
]
;
$currentStore
=
$this
->
storeManager
->
getStore
();
$mediaUrl
=
$currentStore
->
getBaseUrl
(
\Magento\Framework\UrlInterface
::
URL_TYPE_MEDIA
);
...
...
@@ -350,4 +355,17 @@ class GoogleFeed extends Command
return
$name
;
}
public
function
getConfigProductUrl
(
$product
){
$configProductIds
=
$this
->
configurable
->
getParentIdsByChild
(
$product
->
getId
());
if
(
is_array
(
$configProductIds
)
&&
!
empty
(
$configProductIds
)){
$configProductId
=
$configProductIds
[
0
];
}
if
(
is_int
(
$configProductIds
)){
$configProductId
=
$configProductIds
;
}
$configurablProduct
=
$this
->
productRepository
->
getById
(
$configProductId
,
false
,
$product
->
getStoreId
());
$url
=
$configurablProduct
->
getUrlModel
()
->
getUrl
(
$configurablProduct
);
return
$url
;
}
}
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