From 5d13be55b4575a0a16f6e0434999bd72ceb32ae3 Mon Sep 17 00:00:00 2001 From: Hamid Abbaszadeh Date: Tue, 4 Jun 2019 16:40:24 +0430 Subject: [PATCH] Improve product Schema --- src/dca/tl_module.php | 2 +- src/dca/tl_product.php | 9 ++-- src/languages/en/default.php | 36 ++++++++++++--- src/languages/en/tl_product.php | 2 +- src/languages/fa/default.php | 23 ++++++++-- src/library/Frontend/Module/ModuleProduct.php | 44 +++++++++++++------ src/templates/product/product_full.html5 | 36 +++++++++++---- src/templates/product/product_short.html5 | 2 +- 8 files changed, 118 insertions(+), 36 deletions(-) diff --git a/src/dca/tl_module.php b/src/dca/tl_module.php index f32af33..0857061 100644 --- a/src/dca/tl_module.php +++ b/src/dca/tl_module.php @@ -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 ''" diff --git a/src/dca/tl_product.php b/src/dca/tl_product.php index 4d57e8a..6ec729a 100644 --- a/src/dca/tl_product.php +++ b/src/dca/tl_product.php @@ -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 @@ -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 ''" ), @@ -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 ''" ), @@ -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 ''" ), diff --git a/src/languages/en/default.php b/src/languages/en/default.php index 4b026af..370365a 100644 --- a/src/languages/en/default.php +++ b/src/languages/en/default.php @@ -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'; diff --git a/src/languages/en/tl_product.php b/src/languages/en/tl_product.php index 1273e6e..6b27ef1 100644 --- a/src/languages/en/tl_product.php +++ b/src/languages/en/tl_product.php @@ -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.'); diff --git a/src/languages/fa/default.php b/src/languages/fa/default.php index 2e10c0e..384204f 100644 --- a/src/languages/fa/default.php +++ b/src/languages/fa/default.php @@ -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'] = 'تمام'; + diff --git a/src/library/Frontend/Module/ModuleProduct.php b/src/library/Frontend/Module/ModuleProduct.php index eea6cb8..ecc88d2 100644 --- a/src/library/Frontend/Module/ModuleProduct.php +++ b/src/library/Frontend/Module/ModuleProduct.php @@ -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; @@ -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': diff --git a/src/templates/product/product_full.html5 b/src/templates/product/product_full.html5 index 0715a08..e9bd669 100644 --- a/src/templates/product/product_full.html5 +++ b/src/templates/product/product_full.html5 @@ -4,16 +4,36 @@

title; ?>

hasMetaFields): ?> + +
+ meta_brand): ?> + meta_brand_txt; ?>: meta_brand; ?> + + meta_model): ?> + meta_model_txt; ?>: meta_model; ?> + + meta_sku): ?> + meta_sku_txt; ?>: meta_sku; ?> + + meta_barcode): ?> + meta_barcode_txt; ?>: meta_barcode[value]; ?> + +
- meta_brand): ?>meta_brand_txt; ?>: meta_brand; ?> - meta_model): ?>meta_model_txt; ?>: meta_model; ?> - meta_code): ?>meta_code_txt; ?>: meta_code; ?> - meta_sku): ?>meta_sku_txt; ?>: meta_sku; ?> - meta_buy): ?> - +
+ meta_price): ?> + meta_price_txt; ?>: + meta_price[value]); ?> + meta_price[symbol]; ?> + + meta_availability): ?> + (meta_availability_txt; ?>) + + meta_buy): ?> + - - + +
diff --git a/src/templates/product/product_short.html5 b/src/templates/product/product_short.html5 index 54d5a41..c7a085e 100644 --- a/src/templates/product/product_short.html5 +++ b/src/templates/product/product_short.html5 @@ -23,7 +23,7 @@ meta_brand): ?>meta_brand_txt; ?>: meta_brand; ?> meta_model): ?>meta_model_txt; ?>: meta_model; ?> - meta_code): ?>meta_code_txt; ?>: meta_code; ?> + meta_barcode): ?>meta_barcode_txt; ?>: meta_barcode; ?> meta_sku): ?>meta_sku_txt; ?>: meta_sku; ?>