Skip to content

Commit

Permalink
Improve product Schema
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidpeywasti committed Jun 4, 2019
1 parent bb397fc commit 5d13be5
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 36 deletions.
2 changes: 1 addition & 1 deletion src/dca/tl_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
'default' => array(''),
'exclude' => true,
'inputType' => 'checkbox',
'options' => array('date','code','brand','model','sku','buy'),
'options' => array('date','price','availability','brand','model','sku','barcode','buy'),
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('multiple'=>true),
'sql' => "varchar(255) NOT NULL default ''"
Expand Down
9 changes: 6 additions & 3 deletions src/dca/tl_product.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
'palettes' => array
(
'__selector__' => array('addEnclosure','overwriteMeta'),
'default' => '{title_legend},title,alias,date;{offer_legend:hide},price,availability,featured;{meta_legend},pageTitle,description;{product_legend},brand,model,sku,code;{image_legend},singleSRC,overwriteMeta;{related_legend},related;{link_legend:hide},url,target,titleText,linkTitle;{enclosure_legend:hide},addEnclosure;{publish_legend},published,start,stop',
'default' => '{title_legend},title,alias,featured;{meta_legend},pageTitle,date,description;{offer_legend:hide},price,availability;{product_legend},brand,model,sku,barcode;{image_legend},singleSRC,overwriteMeta;{related_legend},related;{link_legend:hide},url,target,titleText,linkTitle;{enclosure_legend:hide},addEnclosure;{publish_legend},published,start,stop',
),

// Subpalettes
Expand Down Expand Up @@ -204,14 +204,15 @@
'eval' => array('maxlength'=>128, 'tl_class'=>'w50'),
'sql' => "varchar(128) NOT NULL default ''"
),
'code' => array
'barcode' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_product']['code'],
'label' => &$GLOBALS['TL_LANG']['tl_product']['barcode'],
'exclude' => true,
'search' => true,
'sorting' => true,
'options' => array('mpn','isbn','gtin8','gtin12','gtin13','gtin14'),
'inputType' => 'inputUnit',
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('includeBlankOption'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
'sql' => "varchar(128) NOT NULL default ''"
),
Expand All @@ -230,6 +231,7 @@
'label' => &$GLOBALS['TL_LANG']['tl_product']['availability'],
'inputType' => 'select',
'options' => array('Discontinued','InStock','InStoreOnly','LimitedAvailability','OnlineOnly','OutOfStock','PreOrder','PreSale','SoldOut'),
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('tl_class'=>'w50'),
'sql' => "varchar(128) NOT NULL default ''"
),
Expand All @@ -241,6 +243,7 @@
'sorting' => true,
'options' => array('RLS','TMN','USD','EUR'),
'inputType' => 'inputUnit',
'reference' => &$GLOBALS['TL_LANG']['MSC'],
'eval' => array('includeBlankOption'=>true, 'maxlength'=>128, 'tl_class'=>'w50'),
'sql' => "varchar(128) NOT NULL default ''"
),
Expand Down
36 changes: 31 additions & 5 deletions src/languages/en/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,42 @@
$GLOBALS['TL_LANG']['MSC']['emptyCatalog'] = 'There is no product!';
$GLOBALS['TL_LANG']['MSC']['moreDetail'] = '%s more details';

$GLOBALS['TL_LANG']['MSC']['price'] = 'Price';
$GLOBALS['TL_LANG']['MSC']['availability'] = 'Availability';
$GLOBALS['TL_LANG']['MSC']['model'] = 'Model';
$GLOBALS['TL_LANG']['MSC']['code'] = 'Code';
$GLOBALS['TL_LANG']['MSC']['barcode'] = 'EAN/UPC';
$GLOBALS['TL_LANG']['MSC']['brand'] = 'Brand';
$GLOBALS['TL_LANG']['MSC']['sku'] = 'SKU';
$GLOBALS['TL_LANG']['MSC']['buy'] = 'Buy link';


$GLOBALS['TL_LANG']['MSC']['model_text'] = 'Product Model';
$GLOBALS['TL_LANG']['MSC']['code_text'] = 'Product Code';
$GLOBALS['TL_LANG']['MSC']['brand_text'] = 'Product Brand';
$GLOBALS['TL_LANG']['MSC']['sku_text'] = 'Product SKU';
$GLOBALS['TL_LANG']['MSC']['Discontinued'] = 'Discontinued';
$GLOBALS['TL_LANG']['MSC']['InStock'] = 'In Stock';
$GLOBALS['TL_LANG']['MSC']['InStoreOnly'] = 'In Store Only';
$GLOBALS['TL_LANG']['MSC']['LimitedAvailability'] = 'Limited Availability';
$GLOBALS['TL_LANG']['MSC']['OnlineOnly'] = 'OnlineOnly';
$GLOBALS['TL_LANG']['MSC']['OutOfStock'] = 'Out Of Stock';
$GLOBALS['TL_LANG']['MSC']['PreOrder'] = 'Pre Order';
$GLOBALS['TL_LANG']['MSC']['PreSale'] = 'Pre Sale';
$GLOBALS['TL_LANG']['MSC']['SoldOut'] = 'Sold Out';

$GLOBALS['TL_LANG']['MSC']['RLS'] = 'Iranian Rial';
$GLOBALS['TL_LANG']['MSC']['TMN'] = 'Iranian Toman';
$GLOBALS['TL_LANG']['MSC']['USD'] = 'US Dollar';
$GLOBALS['TL_LANG']['MSC']['EUR'] = 'Euro';

$GLOBALS['TL_LANG']['MSC']['mpn'] = 'MPN';
$GLOBALS['TL_LANG']['MSC']['isbn'] = 'ISBN';
$GLOBALS['TL_LANG']['MSC']['gtin8'] = 'GTIN-8';
$GLOBALS['TL_LANG']['MSC']['gtin12'] = 'GTIN-12';
$GLOBALS['TL_LANG']['MSC']['gtin13'] = 'GTIN-13';
$GLOBALS['TL_LANG']['MSC']['gtin14'] = 'GTIN-14';

$GLOBALS['TL_LANG']['MSC']['price_text'] = 'Price';
$GLOBALS['TL_LANG']['MSC']['model_text'] = 'Model';
$GLOBALS['TL_LANG']['MSC']['barcode_text'] = 'EAN/UPC';
$GLOBALS['TL_LANG']['MSC']['brand_text'] = 'Brand';
$GLOBALS['TL_LANG']['MSC']['sku_text'] = 'SKU';
$GLOBALS['TL_LANG']['MSC']['status_text'] = 'Status';

$GLOBALS['TL_LANG']['MSC']['relateds_headline'] = 'Related products';
2 changes: 1 addition & 1 deletion src/languages/en/tl_product.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
$GLOBALS['TL_LANG']['tl_product']['availability'] = array('Product availability','Please select availability.');
$GLOBALS['TL_LANG']['tl_product']['brand'] = array('Brand','Please enter the product brand.');
$GLOBALS['TL_LANG']['tl_product']['model'] = array('Model','Please enter the product model.');
$GLOBALS['TL_LANG']['tl_product']['code'] = array('Code','Please enter the product code.');
$GLOBALS['TL_LANG']['tl_product']['barcode'] = array('EAN/UPC','Please enter the product EAN/UPC.');
$GLOBALS['TL_LANG']['tl_product']['sku'] = array('SKU','Please enter the product SKU (Stock Keeping Unit).');
$GLOBALS['TL_LANG']['tl_product']['date'] = array('Date','Please enter the date according to the global date format.');
$GLOBALS['TL_LANG']['tl_product']['url'] = array('Link target','Please enter a web address (http://…), an e-mail address (mailto:…) or an insert tag.');
Expand Down
23 changes: 20 additions & 3 deletions src/languages/fa/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,32 @@
*/

$GLOBALS['TL_LANG']['MSC']['brand_text'] = 'برند';
$GLOBALS['TL_LANG']['MSC']['code_text'] = 'کد محصول';
$GLOBALS['TL_LANG']['MSC']['status_text'] = 'وضعیت';
$GLOBALS['TL_LANG']['MSC']['barcode_text'] = 'کد';
$GLOBALS['TL_LANG']['MSC']['emptyCatalog'] = 'محصولی وجود ندارد!';
$GLOBALS['TL_LANG']['MSC']['features'] = 'ویژگی‌ها';
$GLOBALS['TL_LANG']['MSC']['model_text'] = 'مدل';
$GLOBALS['TL_LANG']['MSC']['price'] = 'قیمت';
$GLOBALS['TL_LANG']['MSC']['rating'] = 'رتبه';
$GLOBALS['TL_LANG']['MSC']['relateds_headline'] = 'محصولات مرتبط';
$GLOBALS['TL_LANG']['MSC']['sku_text'] = '‌اس‌کی‌یو';
$GLOBALS['TL_LANG']['MSC']['price_text'] = 'قیمت';
$GLOBALS['TL_LANG']['MSC']['sku_text'] = 'SKU';
$GLOBALS['TL_LANG']['MSC']['specs'] = 'مشخصات';
$GLOBALS['TL_LANG']['MSC']['types_headline'] = 'نوع‌ها';
$GLOBALS['TL_LANG']['MSC']['types_headline'] = 'انواع';
$GLOBALS['TL_LANG']['MSC']['moreDetail'] = 'جزئیات بیشتر %s';

$GLOBALS['TL_LANG']['MSC']['RLS'] = 'ریال';
$GLOBALS['TL_LANG']['MSC']['TMN'] = 'تومان';
$GLOBALS['TL_LANG']['MSC']['USD'] = 'دلار';
$GLOBALS['TL_LANG']['MSC']['EUR'] = 'یورو';

$GLOBALS['TL_LANG']['MSC']['Discontinued'] = 'عدم تولید';
$GLOBALS['TL_LANG']['MSC']['InStock'] = 'موجود';
$GLOBALS['TL_LANG']['MSC']['InStoreOnly'] = 'In Store Only';
$GLOBALS['TL_LANG']['MSC']['LimitedAvailability'] = 'موجودی محدود';
$GLOBALS['TL_LANG']['MSC']['OnlineOnly'] = 'OnlineOnly';
$GLOBALS['TL_LANG']['MSC']['OutOfStock'] = 'عدم موجودی';
$GLOBALS['TL_LANG']['MSC']['PreOrder'] = 'پیش سفارش';
$GLOBALS['TL_LANG']['MSC']['PreSale'] = 'پیش فروش';
$GLOBALS['TL_LANG']['MSC']['SoldOut'] = 'تمام';

44 changes: 30 additions & 14 deletions src/library/Frontend/Module/ModuleProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,22 @@ public function parseProduct($objProduct, $blnAddCategory=false, $strClass='', $
$arrMeta = $this->getMetaFields($objProduct);

// Add the meta information
$objTemplate->date = $arrMeta['date'];
$objTemplate->meta_brand = $arrMeta['brand'];
$objTemplate->meta_model = $arrMeta['model'];
$objTemplate->meta_code = $arrMeta['code'];
$objTemplate->meta_sku = $arrMeta['sku'];
$objTemplate->meta_buy = $arrMeta['buy'];

$objTemplate->meta_brand_txt = $GLOBALS['TL_LANG']['MSC']['brand_text'];
$objTemplate->meta_model_txt = $GLOBALS['TL_LANG']['MSC']['model_text'];
$objTemplate->meta_code_txt = $GLOBALS['TL_LANG']['MSC']['code_text'];
$objTemplate->meta_sku_txt = $GLOBALS['TL_LANG']['MSC']['sku_text'];
$objTemplate->date = $arrMeta['date'];
$objTemplate->meta_brand = $arrMeta['brand'];
$objTemplate->meta_price = $arrMeta['price'];
$objTemplate->meta_availability = $arrMeta['availability'];
$objTemplate->meta_availability_txt = $GLOBALS['TL_LANG']['MSC'][$objProduct->availability];
$objTemplate->meta_model = $arrMeta['model'];
$objTemplate->meta_barcode = $arrMeta['barcode'];
$objTemplate->meta_sku = $arrMeta['sku'];
$objTemplate->meta_buy = $arrMeta['buy'];

$objTemplate->meta_price_txt = $GLOBALS['TL_LANG']['MSC']['price_text'];
$objTemplate->meta_brand_txt = $GLOBALS['TL_LANG']['MSC']['brand_text'];
$objTemplate->meta_model_txt = $GLOBALS['TL_LANG']['MSC']['model_text'];
$objTemplate->meta_barcode_txt = $GLOBALS['TL_LANG']['MSC']['barcode_text'];
$objTemplate->meta_sku_txt = $GLOBALS['TL_LANG']['MSC']['sku_text'];
$objTemplate->meta_status_txt = $GLOBALS['TL_LANG']['MSC']['status_text'];

$objTemplate->hasMetaFields = !empty($arrMeta);
$objTemplate->timestamp = $objProduct->date;
Expand Down Expand Up @@ -301,9 +306,20 @@ protected function getMetaFields($objProduct)
$return['date'] = \Date::parse($objPage->datimFormat, $objProduct->date);
break;

case 'code':
if ($objProduct->code)
$return['code'] = $objProduct->code;
case 'price':
if ($objProduct->price)
$return['price'] = \StringUtil::deserialize($objProduct->price);
$return['price']['symbol'] = $GLOBALS['TL_LANG']['MSC'][$return['price']['unit']];
break;

case 'availability':
if ($objProduct->availability)
$return['availability'] = $objProduct->availability;
break;

case 'barcode':
if ($objProduct->barcode)
$return['barcode'] = \StringUtil::deserialize($objProduct->barcode);
break;

case 'model':
Expand Down
36 changes: 28 additions & 8 deletions src/templates/product/product_full.html5
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,36 @@
<h1 itemprop="name"><?= $this->title; ?></h1>

<?php if ($this->hasMetaFields): ?>

<div class="meta">
<div class="info">

<time datetime="<?= $this->datetime; ?>"><?= $this->date; ?></time>
<?php if($this->meta_brand): ?>
<span class="brand"><?= $this->meta_brand_txt; ?>: <span itemprop="brand"><?= $this->meta_brand; ?></span></span>
<?php endif; ?>
<?php if($this->meta_model): ?>
<span class="model"><?= $this->meta_model_txt; ?>: <span><?= $this->meta_model; ?></span></span>
<?php endif; ?>
<?php if($this->meta_sku): ?>
<span class="sku"><?= $this->meta_sku_txt; ?>: <span itemprop="sku"><?= $this->meta_sku; ?></span></span>
<?php endif; ?>
<?php if($this->meta_barcode): ?>
<span class="barcode"><?= $this->meta_barcode_txt; ?>: <span itemprop="<?= $this->meta_barcode[unit]; ?>"><?= $this->meta_barcode[value]; ?></span></span>
<?php endif; ?>
</div>

<?php if($this->meta_brand): ?><span class="brand"><?= $this->meta_brand_txt; ?>: <span itemprop="brand"><?= $this->meta_brand; ?></span></span><?php endif; ?>
<?php if($this->meta_model): ?><span class="model"><?= $this->meta_model_txt; ?>: <span><?= $this->meta_model; ?></span></span><?php endif; ?>
<?php if($this->meta_code): ?><span class="code"><?= $this->meta_code_txt; ?>: <span><?= $this->meta_code; ?></span></span><?php endif; ?>
<?php if($this->meta_sku): ?><span class="sku"><?= $this->meta_sku_txt; ?>: <span itemprop="sku"><?= $this->meta_sku; ?></span></span><?php endif; ?>
<?php if($this->meta_buy): ?>
<span itemprop="offers" itemscope itemtype="http://schema.org/Offer" class="buy">
<div class="offers" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<?php if($this->meta_price): ?>
<?= $this->meta_price_txt; ?>:
<span itemprop="price" content="<?= $this->meta_price[value]; ?>"><?= number_format($this->meta_price[value]); ?></span>
<span itemprop="priceCurrency" content="<?= $this->meta_price[unit]; ?>"><?= $this->meta_price[symbol]; ?></span>
<?php endif; ?>
<?php if($this->meta_availability): ?>
<span class="availability"> (<link itemprop="availability" href="http://schema.org/<?= $this->meta_availability; ?>"><?= $this->meta_availability_txt; ?>) </span>
<?php endif; ?>
<?php if($this->meta_buy): ?>
<span class="buy">
<a itemprop="url" href="<?= $this->url ?>" class="hyperlink_txt" title="<?= $this->linkTitle ?>" <?php if($this->target): ?> target="_blank" rel="nofollow" <?php endif; ?> >
<?php if($this->titleText): ?>
<?= $this->titleText ?>
Expand All @@ -22,8 +42,8 @@
<?php endif; ?>
</a>
</span>
<?php endif; ?>

<?php endif; ?>
</div>
</div>


Expand Down
2 changes: 1 addition & 1 deletion src/templates/product/product_short.html5
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<time datetime="<?= $this->datetime; ?>"><?= $this->date; ?></time>
<?php if($this->meta_brand): ?><span class="brand"><?= $this->meta_brand_txt; ?>: <span itemprop="brand"><?= $this->meta_brand; ?></span></span><?php endif; ?>
<?php if($this->meta_model): ?><span class="model"><?= $this->meta_model_txt; ?>: <span><?= $this->meta_model; ?></span></span><?php endif; ?>
<?php if($this->meta_code): ?><span class="code"><?= $this->meta_code_txt; ?>: <span><?= $this->meta_code; ?></span></span><?php endif; ?>
<?php if($this->meta_barcode): ?><span class="barcode"><?= $this->meta_barcode_txt; ?>: <span><?= $this->meta_barcode; ?></span></span><?php endif; ?>
<?php if($this->meta_sku): ?><span class="sku"><?= $this->meta_sku_txt; ?>: <span itemprop="sku"><?= $this->meta_sku; ?></span></span><?php endif; ?>

</div>
Expand Down

0 comments on commit 5d13be5

Please sign in to comment.