Adding structured data / rich snippets to existing code without affecting template
-
22-10-2019 - |
Question
I've been doing some reading and following some tutorials to implement structured data / rich snippets code into my store. It's been easy to follow and understand, however now I'm in a situation where I'd like to add my MPN (Manufacturer Part Number) to the feed.
I have successfully added other schema micro data by simply adding to existing div classes. The problem is that I have a box that is negatively affected by using a div class in line.
<div class="nicebox" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php echo $this->getTierPriceHtml() ?>
<?php echo $this->getChildHtml('alert_urls') ?>
<?php echo $this->getChildHtml('product_type_data') ?>
<div class="mpn" itemprop="mpn"><p><?php echo $this->__('MPN: ') ?><?php echo $_product->getData('mpn')?></p></div>
<p><?php echo $this->__('WEB ID: ') ?><?php echo $_product->getId(); ?></p>
</div>
How can I declare an itemprop inline with my code that would not negatively impact the nicebox class?
Solution
Instead of using div
try and use a span
which should work better inline. Also the class
is not required for microdata so you can leave that out
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange