Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
SeoIndex example
$strategy
=
Shopware
(
)
->
Config
(
)
->
get
(
'seoRefreshStrategy', self::STRATEGY_LIVE
)
;
if
(
$strategy
!== self::STRATEGY_CRON_JOB
)
{
return
true;
}
$shops
=
Shopware
(
)
->
Db
(
)
->
fetchCol
(
'SELECT id FROM s_core_shops WHERE active = 1'
)
;
$currentTime
=
new
DateTime
(
)
;
$this
->
SeoIndex
(
)
->
registerShop
(
$shops
[
0
]
)
;
$this
->
RewriteTable
(
)
->
sCreateRewriteTableCleanup
(
)
;
foreach
(
$shops
as
$shopId
)
{
$repository
=
Shopware
(
)
->
Models
(
)
->
getRepository
(
Shop::
class
)
;
$shop
=
$repository
->
getActiveById
(
$shopId
)
;
if
(
$shop
=== null
)
{
throw
new
Exception
(
'No valid shop id passed'
)
;
}
$this
->
get
(
ShopRegistrationServiceInterface::
class
)
->
registerShop
(
$shop
)
;
Shopware
(
)
->
Modules
(
)
->
Categories
(
)
->baseId =
$shop
->
getCategory
(
)
->
getId
(
)
;
[
,
/** * Clean up seo links. remove links of non-existing categories, articles... */
public
function
initSeoAction
(
)
{
$shopId
=
(int)
$this
->
Request
(
)
->
getParam
(
'shopId', 1
)
;
@
set_time_limit
(
1200
)
;
// Create shop
$this
->
SeoIndex
(
)
->
registerShop
(
$shopId
)
;
$this
->
RewriteTable
(
)
->
baseSetup
(
)
;
$this
->
RewriteTable
(
)
->
sCreateRewriteTableCleanup
(
)
;
$this
->
View
(
)
->
assign
(
[
'success' => true,
]
)
;
}
/** * Assigns the amount of the seo links which to build for this shop * Bind for: Shopware_Controllers_Seo_filterCounts */