Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -1,13 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Browse Store
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Community Suite
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @subpackage Nexus
|
||||
* @since 29 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
|
||||
namespace IPS\nexus\modules\front\store;
|
||||
@@ -152,6 +151,50 @@ class _store extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, $category->_title );
|
||||
\IPS\Output::i()->title = $category->_title;
|
||||
|
||||
/* Add JSON-LD
|
||||
@note Google does not like categories marked up and instead recommends marking up each product separately.
|
||||
@link https://developers.google.com/search/docs/guides/intro-structured-data#multiple-entities-on-the-same-page */
|
||||
foreach( $packages as $package )
|
||||
{
|
||||
$item = \IPS\nexus\Package\Item::load( $package->id );
|
||||
$price = $package->price();
|
||||
|
||||
\IPS\Output::i()->jsonLd['package' . $package->id ] = array(
|
||||
'@context' => "http://schema.org",
|
||||
'@type' => "Product",
|
||||
'name' => $package->_title,
|
||||
'description' => strip_tags( $item->truncated() ),
|
||||
'category' => $category->_title,
|
||||
'url' => (string) $package->url(),
|
||||
'sku' => $package->id,
|
||||
'offers' => array(
|
||||
'@type' => 'Offer',
|
||||
'availability' => ( $package->stock > 0 OR $package->stock == -1 ) ? 'http://schema.org/InStock' : 'http://schema.org/OutOfStock',
|
||||
'price' => $price->amountAsString(),
|
||||
'priceCurrency' => $price->currency,
|
||||
'seller' => array(
|
||||
'@type' => 'Organization',
|
||||
'name' => \IPS\Settings::i()->board_name
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if( $package->image )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['package' . $package->id ]['image'] = (string) $package->image;
|
||||
}
|
||||
|
||||
if( $package->reviewable )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['package' . $package->id ]['aggregateRating'] = array(
|
||||
'@type' => 'AggregateRating',
|
||||
'ratingValue' => $item->averageReviewRating(),
|
||||
'ratingCount' => $item->reviews
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
catch ( \OutofRangeException $e )
|
||||
|
||||
Reference in new issue
Block a user