Invalid Microdata on Single Product View

  • Posts: 127
  • Thank you received: 6
8 years 7 months ago #213305

-- HikaShop version -- : 2.5.0
-- Joomla version -- : 3.4.3
-- PHP version -- : n/a
-- Browser(s) name and version -- : n/a
-- Error-message(debug-mod must be tuned on) -- : n/a

Hi,

We have a number of microdata issues on the single product pages.

The url given is to a test site with all template overrides removed with version 2.5.0 of the producttag plugin installed (also tested with the version from this thread: www.hikashop.com/forum/product-category-...tml-code.html#202188 ).

You can test the url given here to see the issues developers.google.com/structured-data/testing-tool/

Version 2.5.0 is worse so the current installed version is from the forum thread.

1. Aggregate rating requires bestRating and worstRating values and only bestRating is present. Worst can apparently be left out when the vote max is 5 but that value can be changed in hikashop and it never shows on the frontend, also the validator shows invalid even with a max value of 5.

2. Aggregate rating: ratingValue should be the average of all the reviews but currently always shows as 0.

3. Aggregate rating: reviewCount should be an integer but currently also wraps the brackets so the value shows as '( 3 )'

4. Product reviews: Each individual comment has valid review markup, but the review list is wrapped in it's own review itemscope with no author (as it is not actually a review).
<div id="hikashop_product_vote_listing" itemscope itemtype=" schema.org/Review " class="hikashop_product_vote_listing">

For 3, I can see it might be an issue as you are using regex to replace the page code, but you can also add microdata as metatags in the content so rather than wrapping the (3) count, you could append a metatag after the output.

Some more notes:

1. When using Google merchant centre to pickup the cron created feed, products will will show errors and will not auto update if microdata on the site does not match the product availability specified in the product feed.
I have not tested with the display of the availability of the products on the site as our products are always in stock, but adding this value as a metatag within the offer markup would solve this without any visible changes.

2. Also for merchant centre, they recommend always showing the product condition (new, used etc) so it can be used in search and shopping results. This could also be added within the product block as meta without any frontend changes.

Is the plugin from the forum thread the latest available?

Is there any reason why this is added through a plugin rather than directly in the layouts?

Thanks.

Rob

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
8 years 7 months ago #213313

Hi,

Please try to download this latest version of the plugin, we added some fixes for your issue inside.

More than the plugin version, we recommend you to check the views "vote / listing" and "vote / mini" in order to see if there is an override. If it is, the html can be different and the plugin can't do the correct replacements. So you will have to backup the views and reset them.

Attachments:
Last edit: 8 years 7 months ago by Xavier.

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
8 years 7 months ago #213385

Thank You Xavier
Now we have just 1 error:
Field ratingValue may not be empty from
<div class="hikashop_vote_stars" itemprop="aggregateRating" itemscope itemtype=" schema.org/AggregateRating ">

Appreciate your help!

Last edit: 8 years 7 months ago by Bobwales. Reason: Link already hidden in first post

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
8 years 7 months ago #213398

Hi Xavier,

There's only one error showing but there still seems to be missing values that are needed for the ratings to show in search results.

Just to be clear, there are no template overrides, we removed them all for testing, so this the the original component output and the updated producttag plugin.

The votemini is showing reviewCount within aggregateRating, but we are now missing the needed ratingValue, bestRating and worstRating values.

The reviews looks to be fixed!

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
8 years 7 months ago #213457

Hi,

Then edit the file "mini" of the view "product" via the menu Display>Views. There, in the code, you should have that line:

<input type="hidden" name="hikashop_vote_rating" data-type="<?php echo $row->type_item; ?>" data-max="<?php echo $row->hikashop_vote_nb_star; ?>" data-ref="<?php echo $row->vote_ref_id;?>" data-rate="<?php echo $row->hikashop_vote_average_score_rounded; ?>" id="<?php echo $select_id;?>" />
That's what the new version of the plugin proposed by Xavier is looking for in the page. But if you look at the page's HTML code, there is no
<input type="hidden" name="hikashop_vote_rating"
to be found.
So the most probable cause is that you're not using a recent version of that file.
Could you check on that view file ?

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
8 years 7 months ago #213468

Hi,

The most recent hikashop business package available for download (2.5.0) has this code (there is only a mini view within 'vote' not 'product'):

if($vote_status != 'both') {
	if(empty($main_div_name)){ ?>
		<input 	type="hidden" id="hikashop_vote_ref_id" value="<?php echo $hikashop_vote_ref_id;?>"/>
<?php } ?>
	<input 	type="hidden" id="hikashop_vote_ok_<?php echo $hikashop_vote_ref_id;?>" value="0"/>
	<input 	type="hidden" id="vote_type_<?php echo $hikashop_vote_ref_id;?>" value="<?php echo $type_item; ?>"/>
	<input 	type="hidden" id="hikashop_vote_user_id_<?php echo $hikashop_vote_ref_id;?>" value="<?php echo $hikashop_vote_user_id;?>"/>

	<div class="hikashop_vote_stars">
		<input type="hidden" name="hikashop_vote_rating" data-type="<?php echo $type_item; ?>" data-max="<?php echo $hikashop_vote_nb_star; ?>" data-ref="<?php echo $hikashop_vote_ref_id;?>" data-rate="<?php echo $hikashop_vote_average_score_rounded; ?>" id="<?php echo $select_id;?>" />
		<span class="hikashop_total_vote">(<?php echo JHTML::tooltip($hikashop_vote_average_score.'/'.$hikashop_vote_nb_star, JText::_('VOTE_AVERAGE'), '', ' '.$hikashop_vote_total_vote.' '); ?>) </span>
		<span id="hikashop_vote_status_<?php echo $hikashop_vote_ref_id;?>" class="hikashop_vote_notification_mini"></span>
	</div>
<?php
} else { ?>
	<div class="hikashop_vote_stars">
		<div class="ui-rating"><?php
			for($i = 1; $i <= $hikashop_vote_average_score_rounded; $i++) {
				echo '<span class="ui-rating-star ui-rating-full"></span>';
			}
			for($i = $hikashop_vote_average_score_rounded; $i < $hikashop_vote_nb_star; $i++) {
				echo '<span class="ui-rating-star ui-rating-empty"></span>';
			}
		?></div>
		<span class="hikashop_total_vote">(<?php echo JHTML::tooltip($hikashop_vote_average_score.'/'.$hikashop_vote_nb_star, JText::_('VOTE_AVERAGE'), '', ' '.$hikashop_vote_total_vote.' '); ?>) </span>
	</div>
<?php
}

There is an if statement within that file checking for $vote_status != 'both' and if it is equal to both then the hidden inputs are missing.

So it seems that the microdata is correct unless the vote and comment option 'Choose which module you want to enable' is set to 'Vote and Comment Connected'.

Is there any reason for this?

We would like people to leave a comment and vote at the same time but would obviously like the microdata to show correctly.

Also, did you have any thoughts about availability and condition markup?

Last edit: 8 years 7 months ago by Bobwales. Reason: question

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
8 years 7 months ago #214002

Sorry to pester, but is there an alternative to simply commenting out the if($vote_status != 'both') {
and forcing / assuming "Both" are always chosen? That you could recommend? We are happy to revert to an update in the future, if we know that condition will be accommodated in future updates. Otherwise the code gets messy and unpredictable...
Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
8 years 7 months ago #214917

Hi,

The inputs are displayed in the "mini" view within "vote" only when the vote type is not "both" because when it is "both" these inputs are added in the view "form" within "vote". So do you have any override on the view "vote / form" ?

If not, we will have a look at that, as it could be an issue.

In you case, you can potentially remove the if condition to force the display of the hidden inputs.

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
8 years 7 months ago #214956

Hi,

We have no overrides at all, we are just testing the latest component on a development site.

If you check the code within vote/form you will see that the class hikashop_vote_rating does not exist so there is nothing for the plugin to replace.

We could fix this in an override, but it seems that this is a bug in the component. When voting is set to both you will get an itemprop for reviewcount but not the other needed values.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
8 years 7 months ago #214964

Hi,

Please replace the content of the view "vote / mini" by:

<?php
JHTML::_('behavior.tooltip');
$row =& $this->rows;
$config = hikashop_config();
if($row->vote_enabled != 1)
	return;
$row->hikashop_vote_average_score = (float)hikashop_toFloat($row->hikashop_vote_average_score);
JRequest::setVar("rate_rounded",$row->hikashop_vote_average_score_rounded);
JRequest::setVar("nb_max_star",$row->hikashop_vote_nb_star);
$main_div_name = $row->main_div_name;
$hikashop_vote_user_id = hikashop_loadUser();
if(empty($hikashop_vote_user_id))
	$hikashop_vote_user_id = 0;
$select_id = "select_id_".$row->vote_ref_id;
if($main_div_name != '' ){
	$select_id .= "_".$main_div_name;
}else{
	$select_id .= "_hikashop_main_div_name";
}

if($config->get('enable_status_vote', 'vote') != 'both') {
	if(empty($main_div_name)){ ?>
	<input 	type="hidden" id="hikashop_vote_ref_id" value="<?php echo $row->vote_ref_id;?>"/>
<?php } ?>
	<input 	type="hidden" id="hikashop_vote_ok_<?php echo $row->vote_ref_id;?>" value="0"/>
	<input 	type="hidden" id="vote_type_<?php echo $row->vote_ref_id;?>" value="<?php echo $row->type_item; ?>"/>
	<input 	type="hidden" id="hikashop_vote_user_id_<?php echo $row->vote_ref_id;?>" value="<?php echo (int)$hikashop_vote_user_id;?>"/>

	<div class="hikashop_vote_stars">
		<span class="hikashop_total_vote">(<?php echo JHTML::tooltip($row->hikashop_vote_average_score.'/'.$row->hikashop_vote_nb_star, JText::_('VOTE_AVERAGE'), '', ' '.$row->hikashop_vote_total_vote.' '); ?>) </span>
		<span id="hikashop_vote_status_<?php echo $row->vote_ref_id;?>" class="hikashop_vote_notification_mini"></span>

<?php
} else { ?>
	<div class="hikashop_vote_stars">
		<div class="ui-rating"><?php
			for($i = 1; $i <= $row->hikashop_vote_average_score_rounded; $i++) {
				echo '<span class="ui-rating-star ui-rating-full"></span>';
			}
			for($i = $row->hikashop_vote_average_score_rounded; $i < $row->hikashop_vote_nb_star; $i++) {
				echo '<span class="ui-rating-star ui-rating-empty"></span>';
			}
		?></div>
		<span class="hikashop_total_vote">(<?php echo JHTML::tooltip($row->hikashop_vote_average_score.'/'.$row->hikashop_vote_nb_star, JText::_('VOTE_AVERAGE'), '', ' '.$row->hikashop_vote_total_vote.' '); ?>) </span>
<?php
}
?>
		<input type="hidden" name="hikashop_vote_rating" data-type="<?php echo $row->type_item; ?>" data-max="<?php echo $row->hikashop_vote_nb_star; ?>" data-ref="<?php echo $row->vote_ref_id;?>" data-rate="<?php echo $row->hikashop_vote_average_score_rounded; ?>" id="<?php echo $select_id;?>" />
	</div>
This code has been updated on our end and will be present in the next release.

Please Log in or Create an account to join the conversation.

  • Posts: 127
  • Thank you received: 6
8 years 7 months ago #215090

Everything looks good now, thank you very much!

Please consider the option of enabling microdata for condition and stocklevels (Even when the information is not visible to the customer) for Google merchant center feeds.

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
8 years 7 months ago #215093

Hi,

Do you mean these microdatas ?

<span itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition"/>New</span>
<span itemprop="availability" content="http://schema.org/InStock"/>In stock</span>

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
7 years 8 months ago #246839

hi it looks like an error in this code because

search.google.com/structured-data/testing-tool says

<span style="display: none" itemprop="availability" itemscope itemtype=" schema.org/InStock ">in stock</span>

availability
Property availability is unacceptable for the Product object.

how to fix ?

Xavier wrote: Hi,

Do you mean these microdatas ?

<span itemprop="itemCondition" itemtype="http://schema.org/OfferItemCondition" content="http://schema.org/NewCondition"/>New</span>
<span itemprop="availability" content="http://schema.org/InStock"/>In stock</span>

Please Log in or Create an account to join the conversation.

  • Posts: 4533
  • Thank you received: 612
  • MODERATOR
7 years 8 months ago #246902

Hello,

Thanks for you return, we can add a correction for Google Micro Data !
It seems that Google modify Micro Data standards.

I will explain you how to correct this by modifying 4 Views.
First, go to your override views (in Main HikaShop Configuration, on Display dropdown select Views)
Look for your product view :
- show_default.php
- show_reversed.php
- show_tabular.php
- quantity.php

In product/show_default around line 70, in product/show_reversed around line 37 and in product/show_tabular around line 100 you have this :

...
//LAYOUT listing_price
			if ($this->params->get('show_price')) {
				$this->row = & $this->element;
				$this->setLayout('listing_price');
				echo $this->loadTemplate();
				
				//Currency code for Micro Data/request SQL  :
				$CurrId = hikashop_getCurrency();
				$null = null;
				$currency = $this->currencyHelper->getCurrencies($CurrId, $null);
				$CurrCode = $currency[$CurrId]->currency_code;
...
Add between "//LAYOUT listing_price" part and "//Currency code for Micro Data/request SQL :" part this :
...
$availabilty = ($this->row->product_quantity > 0) ? 'In stock' : 'Out of stock';
				echo'<span style="display:none;" itemprop="availability" content=' . $availabilty . '>' . $availabilty . '</span>';
...
To have this :
...
//LAYOUT listing_price
			if ($this->params->get('show_price')) {
				$this->row = & $this->element;
				$this->setLayout('listing_price');
				echo $this->loadTemplate();
				
				$availabilty = ($this->row->product_quantity > 0) ? 'In stock' : 'Out of stock';
				echo'<span style="display:none;" itemprop="availability" content=' . $availabilty . '>' . $availabilty . '</span>';
				
				//Currency code for Micro Data/request SQL  :
				$CurrId = hikashop_getCurrency();
				$null = null;
				$currency = $this->currencyHelper->getCurrencies($CurrId, $null);
				$CurrCode = $currency[$CurrId]->currency_code;
...
And in product/quantity, delete these lines :
around line 145 :
echo '<span style="display:none;" itemprop="availability" itemscope itemtype=" schema.org/InStock ">Out of stock</span>';
To see this :
...
?>
	<div class="hikashop_product_no_stock">
<?php
		echo JText::_('NO_STOCK').'<br/>';
		$waitlist = $this->config->get('product_waitlist', 0);
		if(hikashop_level(1) && ($waitlist == 2 || ($waitlist == 1 && (!empty($this->row->main->product_waitlist) || !empty($this->row->product_waitlist))))) {
?>
...

And around line 112 :
replace these lines :
...
	echo '<span class="hikashop_product_stock_count">'.$text.'<br/></span>'
			. '<span style="display:none;" itemprop="availability" itemscope itemtype="http://schema.org/InStock">in stock</span>';
...
for this :
...
	echo '<span class="hikashop_product_stock_count">'.$text.'<br/></span>';
...

To have this :
...
<div class="hikashop_product_stock">
<?php
		if($this->row->product_quantity == 1 && JText::_('X_ITEM_IN_STOCK') != 'X_ITEM_IN_STOCK')
			$text = JText::sprintf('X_ITEM_IN_STOCK', $this->row->product_quantity);
		else
			$text = JText::sprintf('X_ITEMS_IN_STOCK', $this->row->product_quantity);

		echo '<span class="hikashop_product_stock_count">'.$text.'<br/></span>';
		
		if($this->config->get('button_style', 'normal') == 'css')
			echo '<br />';
...

Note : that we include this correction for futur HikaShop release.
Hope that will solve your issue.

Regards

Last edit: 7 years 8 months ago by Philip.

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
7 years 8 months ago #246978

thank you very much for such detailed help

i will fix code bysellf and will wait for next hikashop update

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
7 years 8 months ago #247096

Philip wrote: Hello,

Add between "//LAYOUT listing_price" part and "//Currency code for Micro Data/request SQL :" part this :

...
$availabilty = ($this->row->product_quantity > 0) ? 'In stock' : 'Out of stock';
				echo'<span style="display:none;" itemprop="availability" content=' . $availabilty . '>' . $availabilty . '</span>';
...

Note : that we include this correction for futur HikaShop release.
Hope that will solve your issue.

Regards


i think you forgot to add quotes in content='.$available.'
...
$availabilty = ($this->row->product_quantity > 0) ? 'In stock' : 'Out of stock';
				echo'<span style="display:none;" itemprop="availability" content="' . $availabilty . '">' . $availabilty . '</span>';
...

Please Log in or Create an account to join the conversation.

  • Posts: 4533
  • Thank you received: 612
  • MODERATOR
7 years 8 months ago #247097

Hello,

Does your issue is solved ? That the most important point, and I don't understand what I forgot...
your sample code is the same than mine.

Regards

The following user(s) said Thank You: Bender

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
7 years 8 months ago #247132

Philip wrote: Hello,

Does your issue is solved ? That the most important point, and I don't understand what I forgot...
your sample code is the same than mine.

Regards


you forgot to add double quotes here content='. $availabilty . '>'
i added double qoutes and it passed check on google microdata check page content="' . $availabilty . '">'

but you code is a good code
the issue is solved

Last edit: 7 years 8 months ago by Bender.

Please Log in or Create an account to join the conversation.

  • Posts: 81562
  • Thank you received: 13071
  • MODERATOR
7 years 8 months ago #247140

Thanks. It's fixed on our end :)

Please Log in or Create an account to join the conversation.

  • Posts: 210
  • Thank you received: 4
  • Hikashop Business
7 years 8 months ago #247355

nicolas wrote: Thanks. It's fixed on our end :)

hi Nicolas!

Please explain how to disable "add to wait list" button on category view and enable this button on product page ?
i found a piece of code in quantity.php but i cant find any linked code in show tabular and image_title.php

Please Log in or Create an account to join the conversation.

Time to create page: 0.112 seconds
Powered by Kunena Forum