PHP Classes

File: Product_Example.php

Recommend this page to a friend!
  Classes of Orazio Principe   PHP Microdata Generator   Product_Example.php   Download  
File: Product_Example.php
Role: Example script
Content type: text/plain
Description: Product example microdata
Class: PHP Microdata Generator
Generate semantic HTML tags following schema.org
Author: By
Last change: changed extension, accessible without user login
Date: 10 years ago
Size: 1,929 bytes
 

Contents

Class file image Download
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Microdata for Products</title>
    </head>
    <body>
        <?php
       
require_once("MicrodataGenerator.php");

       
$product = new Microdata\Product();

       
$product->setName("example name");
       
$product->setUrl("principeorazio.wordpress.com");
       
$product->setDescription("short description for the product");
       
$product->setBrand("Principe Orazio");
       
$product->setManufacturer("Princex");
       
$product->setModel("Microdata Tag Generator");
       
$product->setProductId("1");
       
$product->setRatingValue(4);
       
$product->setReviewsCount(8);
       
$product->setPrice("100 €");
       
$product->setCondition(\Microdata\iMicrodata::CONDITION_NEW, "new");

        echo
$product->getCompleteCode();
       
?>

        <hr />
        Example using single terms
        <?=$product->openSchemaCode()?>
<?=$product->getUrlCode()?>
<?=$product->getDescriptionCode()?>
<?=$product->getBrandCode("Brand: ")?>
<?=$product->getManufacturerCode("Manufactor: ")?>
<div>Model: <?=$product->getModelCode()?></div>
        <div>Product ID: <?=$product->getProductIdCode()?></div>
        <div>
            <?=$product->getAggregateRating()->openSchemaCode()?>
<span>Stars <?=$product->getAggregateRating()->getRatingValueCode()?></span>
            <span>Based on <?=$product->getAggregateRating()->getReviewCountCode()?> reviews</span>
            <?=$product->getAggregateRating()->closeSchemaCode()?>
</div>
        <div>
            <?=$product->getOffer()->openSchemaCode()?>
Price
            <?=$product->getOffer()->getPriceCode()?>
<?=$product->getOffer()->closeSchemaCode()?>
</div>
        <?=$product->closeSchemaCode()?>

    </body>
</html>