From 69c79dc6494798a6f13e99ccbe9db1616145d5f3 Mon Sep 17 00:00:00 2001 From: giaphn Date: Thu, 3 Mar 2022 10:46:16 +0700 Subject: [PATCH 01/18] - Update bussiness structure data --- Model/Config/Backend/BussinessImage.php | 64 +++ Plugin/SeoRender.php | 63 ++- etc/adminhtml/system.xml | 583 +++++++++++++----------- 3 files changed, 440 insertions(+), 270 deletions(-) create mode 100644 Model/Config/Backend/BussinessImage.php diff --git a/Model/Config/Backend/BussinessImage.php b/Model/Config/Backend/BussinessImage.php new file mode 100644 index 0000000..8e5a407 --- /dev/null +++ b/Model/Config/Backend/BussinessImage.php @@ -0,0 +1,64 @@ +_mediaDirectory->getAbsolutePath($this->_appendScopeInfo(self::UPLOAD_DIR)); + } + + /** + * Makes a decision about whether to add info about the scope. + * + * @return boolean + */ + protected function _addWhetherScopeInfo() + { + return true; + } + + /** + * Getter for allowed extensions of uploaded files. + * + * @return string[] + */ + protected function _getAllowedExtensions() + { + return ['jpg', 'jpeg', 'png', 'svg']; + } +} diff --git a/Plugin/SeoRender.php b/Plugin/SeoRender.php index d865797..5688194 100755 --- a/Plugin/SeoRender.php +++ b/Plugin/SeoRender.php @@ -310,7 +310,8 @@ public function afterRenderHeadContent(Renderer $subject, $result) break; case 'cms_index_index': if ($this->helperData->getInfoConfig('enable')) { - $result .= $this->showBusinessStructuredData(); + $result .= $this->showLogoStructureData(); + $result .= $this->showLocalBussinessStructureData(); } if ($this->helperData->getRichsnippetsConfig('enable_site_link')) { $result .= $this->showSiteLinksStructuredData(); @@ -771,13 +772,13 @@ public function getRatingSummary() } /** - * get Business Structured Data + * Get Logo Structured Data * * @return string */ - public function showBusinessStructuredData() + public function showLogoStructureData() { - $businessStructuredData = [ + $logoStructureData = [ '@context' => 'http://schema.org/', '@type' => 'Organization', 'url' => $this->getUrl(), @@ -786,7 +787,7 @@ public function showBusinessStructuredData() 'contactPoint' => [] ]; if (!empty($this->getSocialProfiles())) { - $businessStructuredData['sameAs'] = $this->getSocialProfiles(); + $logoStructureData['sameAs'] = $this->getSocialProfiles(); } // get customer service info @@ -794,7 +795,7 @@ public function showBusinessStructuredData() || $this->helperData->getInfoConfig('customer_service_contact_option') || $this->helperData->getInfoConfig('customer_service_area_serve') ) { - $businessStructuredData['contactPoint'][] = [ + $logoStructureData['contactPoint'][] = [ '@type' => 'ContactPoint', 'telephone' => $this->helperData->getInfoConfig('customer_service_phone'), 'contactType' => 'customer service', @@ -807,7 +808,7 @@ public function showBusinessStructuredData() || $this->helperData->getInfoConfig('technical_support_contact_option') || $this->helperData->getInfoConfig('technical_support_area_serve') ) { - $businessStructuredData['contactPoint'][] = [ + $logoStructureData['contactPoint'][] = [ '@type' => 'ContactPoint', 'telephone' => $this->helperData->getInfoConfig('technical_support_phone'), 'contactType' => 'technical support', @@ -820,7 +821,7 @@ public function showBusinessStructuredData() || $this->helperData->getInfoConfig('sales_contact_option') || $this->helperData->getInfoConfig('sales_area_serve') ) { - $businessStructuredData['contactPoint'][] = [ + $logoStructureData['contactPoint'][] = [ '@type' => 'ContactPoint', 'telephone' => $this->helperData->getInfoConfig('sales_phone'), 'contactType' => 'sales', @@ -830,8 +831,50 @@ public function showBusinessStructuredData() } return $this->helperData->createStructuredData( - $businessStructuredData, - '' + $logoStructureData, + '' + ); + } + + /** + * Get Local Bussiness Structure data. + * + * @return string + * @throws NoSuchEntityException + */ + public function showLocalBussinessStructureData() + { + $localBussinessStructureData = [ + '@context' => 'http://schema.org/', + '@type' => 'Store', + 'name' => $this->helperData->getInfoConfig('business_name'), + 'address' => [ + '@type' => 'PostalAddress', + 'streetAddress' => $this->helperData->getInfoConfig('street_address'), + 'addressLocality' => $this->helperData->getInfoConfig('city'), + 'addressRegion' => $this->helperData->getInfoConfig('state_province'), + 'addressCountry' => $this->helperData->getConfigValue('general/country/default'), + 'postalCode' => $this->helperData->getInfoConfig('zip_code'), + 'email' => $this->helperData->getInfoConfig('email'), + 'faxNumber' => $this->helperData->getInfoConfig('fax') + ], + 'telephone' => $this->helperData->getInfoConfig('customer_service_phone'), + 'priceRange' => $this->helperData->getInfoConfig('price_range'), + 'description' => $this->helperData->getInfoConfig('description') + ]; + + $bussinessImages = $this->helperData->getInfoConfig('image_url') + ? explode(',', $this->helperData->getInfoConfig('image_url')) : []; + if ($this->helperData->getInfoConfig('image')) { + $image = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) + . 'mageplaza/seo/' . $this->helperData->getInfoConfig('image'); + $bussinessImages[] = $image; + } + $localBussinessStructureData['image'] = $bussinessImages; + + return $this->helperData->createStructuredData( + $localBussinessStructureData, + '' ); } diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 0bbb320..60361fe 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1,260 +1,323 @@ - - - - -
- separator-top - - mageplaza - Mageplaza_Seo::configuration - - - - Mageplaza\Core\Block\Adminhtml\System\Config\Head - -
  • User Guide
  • -
  • Boost up to ↑198% site traffic, ↑32% site ranking with Learn more
  • -
  • Helpdesk
  • -
  • Request features
  • -
  • Increase 25% conversion rate with Layered Navigation
  • -
  • Magento stores see upwards of 30% revenue 💰 with AVADA. Learn more
  • - - ]]>
    -
    - - - Magento\Config\Model\Config\Source\Yesno - -
    - - - - - Magento\Config\Model\Config\Source\Yesno - Avoid duplicate content. - - - - Magento\Config\Model\Config\Source\Yesno - Avoid duplicate content. - - - - - - - Magento\Config\Model\Config\Source\Yesno - Learn more ]]> - - - - Mageplaza\Seo\Model\Config\Source\Attribute - - 1 - - required-entry - - - - - 1 - - Mageplaza\Seo\Model\Config\Source\PriceValidUntil - - - - - 1 - custom - - Mageplaza\Seo\Block\Adminhtml\System\Config\Date - required-entry - - - - - 1 - - Mageplaza\Seo\Model\Config\Source\ModelField - here ]]> - - - - - 1 - - Mageplaza\Seo\Model\Config\Source\Attribute - required-entry - Recommend field: sku, barcode - - - - Magento\Config\Model\Config\Source\Yesno - here ]]> - - - - - - - Magento\Config\Model\Config\Source\Yesno - here ]]> - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - 1 - - - - - - - - - validate-url - Learn more]]> - - - - validate-url - Learn more]]> - - - - validate-url - Learn more]]> - - - - validate-url - Learn more]]> - - - - validate-url - Learn more]]> - - - - validate-url - Learn more]]> - - - - validate-url - Learn more]]> - - - - validate-url - Learn more]]> - - - - validate-url - Learn more]]> - - - - validate-url - Learn more]]> - - - - - - - tag]]> - - - - tag]]> - - - - tag]]> - - - - tag]]> - - -
    -
    -
    + + + + +
    + separator-top + + mageplaza + Mageplaza_Seo::configuration + + + + Mageplaza\Core\Block\Adminhtml\System\Config\Head + +
  • User Guide
  • +
  • Boost up to ↑198% site traffic, ↑32% site ranking with Learn more
  • +
  • Helpdesk
  • +
  • Request features
  • +
  • Increase 25% conversion rate with Layered Navigation
  • +
  • Magento stores see upwards of 30% revenue 💰 with AVADA. Learn more
  • + + ]]>
    +
    + + + Magento\Config\Model\Config\Source\Yesno + +
    + + + + + Magento\Config\Model\Config\Source\Yesno + Avoid duplicate content. + + + + Magento\Config\Model\Config\Source\Yesno + Avoid duplicate content. + + + + + + + Magento\Config\Model\Config\Source\Yesno + Learn more ]]> + + + + Mageplaza\Seo\Model\Config\Source\Attribute + + 1 + + required-entry + + + + + 1 + + Mageplaza\Seo\Model\Config\Source\PriceValidUntil + + + + + 1 + custom + + Mageplaza\Seo\Block\Adminhtml\System\Config\Date + required-entry + + + + + 1 + + Mageplaza\Seo\Model\Config\Source\ModelField + here ]]> + + + + + 1 + + Mageplaza\Seo\Model\Config\Source\Attribute + required-entry + Recommend field: sku, barcode + + + + Magento\Config\Model\Config\Source\Yesno + here ]]> + + + + + + + Magento\Config\Model\Config\Source\Yesno + here ]]> + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + Mageplaza\Seo\Model\Config\Backend\BussinessImage + mageplaza/seo + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + 1 + + + + + + + 1 + + + + + + 1 + + + + + + + + + validate-url + Learn more]]> + + + + validate-url + Learn more]]> + + + + validate-url + Learn more]]> + + + + validate-url + Learn more]]> + + + + validate-url + Learn more]]> + + + + validate-url + Learn more]]> + + + + validate-url + Learn more]]> + + + + validate-url + Learn more]]> + + + + validate-url + Learn more]]> + + + + validate-url + Learn more]]> + + + + + + + tag]]> + + + + tag]]> + + + + tag]]> + + + + tag]]> + + +
    +
    +
    From e22938a48b2e706885e9c6c446e95a71bc1936ce Mon Sep 17 00:00:00 2001 From: giaphn Date: Thu, 3 Mar 2022 17:18:25 +0700 Subject: [PATCH 02/18] - Update bussiness structure data --- Model/Config/Source/BussinessType.php | 72 +++++++++++++++++++++++++++ Plugin/SeoRender.php | 4 +- etc/adminhtml/system.xml | 7 +++ 3 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 Model/Config/Source/BussinessType.php diff --git a/Model/Config/Source/BussinessType.php b/Model/Config/Source/BussinessType.php new file mode 100644 index 0000000..9b552bd --- /dev/null +++ b/Model/Config/Source/BussinessType.php @@ -0,0 +1,72 @@ + __('--Please Select--'), 'value' => 'Store'], + ['label' => __('LocalBussiness'), 'value' => 'LocalBussiness'], + ['label' => __('AutoPartsStore'), 'value' => 'AutoPartsStore'], + ['label' => __('BikeStore'), 'value' => 'BikeStore'], + ['label' => __('BookStore'), 'value' => 'BookStore'], + ['label' => __('ClothingStore'), 'value' => 'ClothingStore'], + ['label' => __('ComputerStore'), 'value' => 'ComputerStore'], + ['label' => __('ConvenienceStore'), 'value' => 'ConvenienceStore'], + ['label' => __('DepartmentStore'), 'value' => 'DepartmentStore'], + ['label' => __('ElectronicsStore'), 'value' => 'ElectronicsStore'], + ['label' => __('Florist'), 'value' => 'Florist'], + ['label' => __('FurnitureStore'), 'value' => 'FurnitureStore'], + ['label' => __('GardenStore'), 'value' => 'GardenStore'], + ['label' => __('GroceryStore'), 'value' => 'GroceryStore'], + ['label' => __('HardwareStore'), 'value' => 'HardwareStore'], + ['label' => __('HobbyShop'), 'value' => 'HobbyShop'], + ['label' => __('HomeGoodsStore'), 'value' => 'HomeGoodsStore'], + ['label' => __('JewelryStore'), 'value' => 'JewelryStore'], + ['label' => __('LiquorStore'), 'value' => 'LiquorStore'], + ['label' => __('MensClothingStore'), 'value' => 'MensClothingStore'], + ['label' => __('MobilePhoneStore'), 'value' => 'MobilePhoneStore'], + ['label' => __('MovieRentalStore'), 'value' => 'MovieRentalStore'], + ['label' => __('MusicStoreMusicStore'), 'value' => 'MusicStore'], + ['label' => __('OfficeEquipmentStore'), 'value' => 'OfficeEquipmentStore'], + ['label' => __('OutletStore'), 'value' => 'OutletStore'], + ['label' => __('PawnShop'), 'value' => 'PawnShop'], + ['label' => __('PetStore'), 'value' => 'PetStore'], + ['label' => __('ShoeStore'), 'value' => 'ShoeStore'], + ['label' => __('SportingGoodsStore'), 'value' => 'SportingGoodsStore'], + ['label' => __('TireShop'), 'value' => 'TireShop'], + ['label' => __('ToyStore'), 'value' => 'ToyStore'], + ['label' => __('WholesaleStore'), 'value' => 'WholesaleStore'], + ]; + } +} diff --git a/Plugin/SeoRender.php b/Plugin/SeoRender.php index 5688194..50b89dd 100755 --- a/Plugin/SeoRender.php +++ b/Plugin/SeoRender.php @@ -846,7 +846,7 @@ public function showLocalBussinessStructureData() { $localBussinessStructureData = [ '@context' => 'http://schema.org/', - '@type' => 'Store', + '@type' => $this->helperData->getInfoConfig('business_type'), 'name' => $this->helperData->getInfoConfig('business_name'), 'address' => [ '@type' => 'PostalAddress', @@ -858,7 +858,7 @@ public function showLocalBussinessStructureData() 'email' => $this->helperData->getInfoConfig('email'), 'faxNumber' => $this->helperData->getInfoConfig('fax') ], - 'telephone' => $this->helperData->getInfoConfig('customer_service_phone'), + 'telephone' => $this->helperData->getInfoConfig('customer_service_phone'), 'priceRange' => $this->helperData->getInfoConfig('price_range'), 'description' => $this->helperData->getInfoConfig('description') ]; diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 60361fe..ce0c0d7 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -127,6 +127,13 @@ 1 + + + + 1 + + Mageplaza\Seo\Model\Config\Source\BussinessType + From 80b213cedaf2fd54ed212c0121d351e765ddec04 Mon Sep 17 00:00:00 2001 From: giaphn Date: Thu, 3 Mar 2022 17:24:44 +0700 Subject: [PATCH 03/18] - Clean code --- Plugin/SeoRender.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Plugin/SeoRender.php b/Plugin/SeoRender.php index 50b89dd..be83441 100755 --- a/Plugin/SeoRender.php +++ b/Plugin/SeoRender.php @@ -294,9 +294,10 @@ public function getFullActionName() /** * @param Renderer $subject - * @param string $result + * @param $result * - * @return string + * @return mixed|string + * @throws NoSuchEntityException */ public function afterRenderHeadContent(Renderer $subject, $result) { @@ -556,12 +557,12 @@ public function addProductStructuredDataByType($productType, $currentProduct, $p } /** - * add Grouped Product Structured Data + * Add Grouped Product Structured Data * * @param Product $currentProduct * @param array $productStructuredData * - * @return mixed + * @return array * @throws NoSuchEntityException */ public function getGroupedProductStructuredData($currentProduct, $productStructuredData) @@ -598,12 +599,12 @@ public function getGroupedProductStructuredData($currentProduct, $productStructu } /** - * add Bundle Product Structured Data + * Add Bundle Product Structured Data * * @param Product $currentProduct * @param array $productStructuredData * - * @return mixed + * @return array * @throws NoSuchEntityException */ public function getBundleProductStructuredData($currentProduct, $productStructuredData) @@ -646,12 +647,12 @@ public function getBundleProductStructuredData($currentProduct, $productStructur } /** - * add Downloadable Product Structured Data + * Add Downloadable Product Structured Data * * @param Product $currentProduct * @param array $productStructuredData * - * @return mixed + * @return array */ public function getDownloadableProductStructuredData($currentProduct, $productStructuredData) { From 7f99f49f8faeca653e5339a9b76e7d2359d4017a Mon Sep 17 00:00:00 2001 From: giaphn Date: Fri, 4 Mar 2022 09:21:48 +0700 Subject: [PATCH 04/18] - Update bussiness configuration --- etc/adminhtml/system.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index ce0c0d7..af31cf2 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -117,7 +117,7 @@ - + Magento\Config\Model\Config\Source\Yesno here ]]> @@ -130,7 +130,7 @@ - 1 + 1 Mageplaza\Seo\Model\Config\Source\BussinessType From bac41d3e0699ef8f30ce45a125ecc9d0246bdf4a Mon Sep 17 00:00:00 2001 From: giaphn Date: Fri, 4 Mar 2022 15:37:38 +0700 Subject: [PATCH 05/18] - Update validation --- etc/adminhtml/system.xml | 7 +++- view/adminhtml/requirejs-config.js | 29 +++++++++++++++ .../js/admin-config/validator-rules-mixin.js | 36 +++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 view/adminhtml/requirejs-config.js create mode 100644 view/adminhtml/web/js/admin-config/validator-rules-mixin.js diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index af31cf2..1f776ce 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -129,13 +129,14 @@ + Mageplaza\Seo\Model\Config\Source\BussinessType 1 - Mageplaza\Seo\Model\Config\Source\BussinessType + validate-phone-number 1 @@ -154,6 +155,7 @@ + validate-phone-number 1 @@ -172,6 +174,7 @@ + validate-phone-number 1 @@ -228,12 +231,14 @@ + validate-email 1 + validate-fax 1 diff --git a/view/adminhtml/requirejs-config.js b/view/adminhtml/requirejs-config.js new file mode 100644 index 0000000..3b632a9 --- /dev/null +++ b/view/adminhtml/requirejs-config.js @@ -0,0 +1,29 @@ +/** + * Mageplaza + * + * NOTICE OF LICENSE + * + * This source file is subject to the Mageplaza.com license that is + * available through the world-wide-web at this URL: + * https://www.mageplaza.com/LICENSE.txt + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade this extension to newer + * version in the future. + * + * @category Mageplaza + * @package Mageplaza_Seo + * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) + * @license https://www.mageplaza.com/LICENSE.txt + */ + +var config = { + config: { + mixins: { + 'mage/validation': { + 'Mageplaza_Seo/js/admin-config/validator-rules-mixin': true + } + } + } +}; diff --git a/view/adminhtml/web/js/admin-config/validator-rules-mixin.js b/view/adminhtml/web/js/admin-config/validator-rules-mixin.js new file mode 100644 index 0000000..539a99a --- /dev/null +++ b/view/adminhtml/web/js/admin-config/validator-rules-mixin.js @@ -0,0 +1,36 @@ +/** + * Mageplaza + * + * NOTICE OF LICENSE + * + * This source file is subject to the Mageplaza.com license that is + * available through the world-wide-web at this URL: + * https://www.mageplaza.com/LICENSE.txt + * + * DISCLAIMER + * + * Do not edit or add to this file if you wish to upgrade this extension to newer + * version in the future. + * + * @category Mageplaza + * @package Mageplaza_Seo + * @copyright Copyright (c) Mageplaza (https://www.mageplaza.com/) + * @license https://www.mageplaza.com/LICENSE.txt + */ + +define([ + 'jquery' +], function ($) { + 'use strict'; + return function (target) { + $.validator.addMethod( + 'validate-phone-number', + function (value) { + var regex = new RegExp(/^\+(?:\d(?:\(\d{3}\)|-\d{3})-\d{3}-(?:\d{2}-\d{2}|\d{4})|\d{11})$/); + return !(regex.match(value)); + }, + $.mage.__('Please enter a valid phone number') + ); + return target; + }; +}); From 54b8a5531e2db4463e9ee66b18ac64df9a05abca Mon Sep 17 00:00:00 2001 From: giaphn Date: Fri, 4 Mar 2022 15:43:53 +0700 Subject: [PATCH 06/18] - Update validation --- view/adminhtml/web/js/admin-config/validator-rules-mixin.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/view/adminhtml/web/js/admin-config/validator-rules-mixin.js b/view/adminhtml/web/js/admin-config/validator-rules-mixin.js index 539a99a..05c6043 100644 --- a/view/adminhtml/web/js/admin-config/validator-rules-mixin.js +++ b/view/adminhtml/web/js/admin-config/validator-rules-mixin.js @@ -27,7 +27,10 @@ define([ 'validate-phone-number', function (value) { var regex = new RegExp(/^\+(?:\d(?:\(\d{3}\)|-\d{3})-\d{3}-(?:\d{2}-\d{2}|\d{4})|\d{11})$/); - return !(regex.match(value)); + if (value.length) { + return regex.match(value); + } + return true; }, $.mage.__('Please enter a valid phone number') ); From fc9d0f4e8539111e6b086c33be6eb69f88bca6e4 Mon Sep 17 00:00:00 2001 From: giaphn Date: Fri, 4 Mar 2022 17:15:52 +0700 Subject: [PATCH 07/18] - Update bussiness structure data --- view/adminhtml/web/js/admin-config/validator-rules-mixin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/adminhtml/web/js/admin-config/validator-rules-mixin.js b/view/adminhtml/web/js/admin-config/validator-rules-mixin.js index 05c6043..762ffea 100644 --- a/view/adminhtml/web/js/admin-config/validator-rules-mixin.js +++ b/view/adminhtml/web/js/admin-config/validator-rules-mixin.js @@ -26,7 +26,7 @@ define([ $.validator.addMethod( 'validate-phone-number', function (value) { - var regex = new RegExp(/^\+(?:\d(?:\(\d{3}\)|-\d{3})-\d{3}-(?:\d{2}-\d{2}|\d{4})|\d{11})$/); + var regex = new RegExp(/\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/); if (value.length) { return regex.match(value); } From 6d24850111c7358be248ec684d50ee92188c8421 Mon Sep 17 00:00:00 2001 From: giaphn Date: Mon, 7 Mar 2022 11:14:58 +0700 Subject: [PATCH 08/18] - Update validation --- view/adminhtml/web/js/admin-config/validator-rules-mixin.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/view/adminhtml/web/js/admin-config/validator-rules-mixin.js b/view/adminhtml/web/js/admin-config/validator-rules-mixin.js index 762ffea..c15ba2d 100644 --- a/view/adminhtml/web/js/admin-config/validator-rules-mixin.js +++ b/view/adminhtml/web/js/admin-config/validator-rules-mixin.js @@ -26,11 +26,12 @@ define([ $.validator.addMethod( 'validate-phone-number', function (value) { - var regex = new RegExp(/\(?([0-9]{3})\)?([ .-]?)([0-9]{3})\2([0-9]{4})/); + var regex = new RegExp(/^((\+\d{1,3}(-| )?\(?\d\)?(-| )?\d{1,5})|(\(?\d{2,6}\)?))(-| )?(\d{3,4})(-| )?(\d{4})(( x| ext)\d{1,5}){0,1}$/); if (value.length) { return regex.match(value); + } else { + return true; } - return true; }, $.mage.__('Please enter a valid phone number') ); From 8061c72123aa728a83999be4e913452f7f0b1859 Mon Sep 17 00:00:00 2001 From: giaphn Date: Mon, 7 Mar 2022 16:06:17 +0700 Subject: [PATCH 09/18] Fix bug image field in local bussiness structure data --- Plugin/SeoRender.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Plugin/SeoRender.php b/Plugin/SeoRender.php index be83441..4a23af7 100755 --- a/Plugin/SeoRender.php +++ b/Plugin/SeoRender.php @@ -864,8 +864,7 @@ public function showLocalBussinessStructureData() 'description' => $this->helperData->getInfoConfig('description') ]; - $bussinessImages = $this->helperData->getInfoConfig('image_url') - ? explode(',', $this->helperData->getInfoConfig('image_url')) : []; + $bussinessImages = $this->getBussinessImageUrlConfig(); if ($this->helperData->getInfoConfig('image')) { $image = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) . 'mageplaza/seo/' . $this->helperData->getInfoConfig('image'); @@ -879,6 +878,20 @@ public function showLocalBussinessStructureData() ); } + /** + * @return array + */ + protected function getBussinessImageUrlConfig() + { + if ($this->helperData->getInfoConfig('image_url')) { + return array_map('trim', explode( + "\n", + $this->helperData->getInfoConfig('image_url') + )); + } + return []; + } + /** * get Social Profiles config * From d702312c207a9a279c025204d227987a3e665e07 Mon Sep 17 00:00:00 2001 From: giaphn Date: Mon, 28 Mar 2022 14:50:37 +0700 Subject: [PATCH 10/18] - Update Bussiness Type --- Model/Config/Source/BussinessType.php | 60 +++++++++++++-------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/Model/Config/Source/BussinessType.php b/Model/Config/Source/BussinessType.php index 9b552bd..567e9b1 100644 --- a/Model/Config/Source/BussinessType.php +++ b/Model/Config/Source/BussinessType.php @@ -36,37 +36,35 @@ public function toOptionArray() { return [ ['label' => __('--Please Select--'), 'value' => 'Store'], - ['label' => __('LocalBussiness'), 'value' => 'LocalBussiness'], - ['label' => __('AutoPartsStore'), 'value' => 'AutoPartsStore'], - ['label' => __('BikeStore'), 'value' => 'BikeStore'], - ['label' => __('BookStore'), 'value' => 'BookStore'], - ['label' => __('ClothingStore'), 'value' => 'ClothingStore'], - ['label' => __('ComputerStore'), 'value' => 'ComputerStore'], - ['label' => __('ConvenienceStore'), 'value' => 'ConvenienceStore'], - ['label' => __('DepartmentStore'), 'value' => 'DepartmentStore'], - ['label' => __('ElectronicsStore'), 'value' => 'ElectronicsStore'], - ['label' => __('Florist'), 'value' => 'Florist'], - ['label' => __('FurnitureStore'), 'value' => 'FurnitureStore'], - ['label' => __('GardenStore'), 'value' => 'GardenStore'], - ['label' => __('GroceryStore'), 'value' => 'GroceryStore'], - ['label' => __('HardwareStore'), 'value' => 'HardwareStore'], - ['label' => __('HobbyShop'), 'value' => 'HobbyShop'], - ['label' => __('HomeGoodsStore'), 'value' => 'HomeGoodsStore'], - ['label' => __('JewelryStore'), 'value' => 'JewelryStore'], - ['label' => __('LiquorStore'), 'value' => 'LiquorStore'], - ['label' => __('MensClothingStore'), 'value' => 'MensClothingStore'], - ['label' => __('MobilePhoneStore'), 'value' => 'MobilePhoneStore'], - ['label' => __('MovieRentalStore'), 'value' => 'MovieRentalStore'], - ['label' => __('MusicStoreMusicStore'), 'value' => 'MusicStore'], - ['label' => __('OfficeEquipmentStore'), 'value' => 'OfficeEquipmentStore'], - ['label' => __('OutletStore'), 'value' => 'OutletStore'], - ['label' => __('PawnShop'), 'value' => 'PawnShop'], - ['label' => __('PetStore'), 'value' => 'PetStore'], - ['label' => __('ShoeStore'), 'value' => 'ShoeStore'], - ['label' => __('SportingGoodsStore'), 'value' => 'SportingGoodsStore'], - ['label' => __('TireShop'), 'value' => 'TireShop'], - ['label' => __('ToyStore'), 'value' => 'ToyStore'], - ['label' => __('WholesaleStore'), 'value' => 'WholesaleStore'], + ['label' => __('Animal Shelter'), 'value' => 'AnimalShelter'], + ['label' => __('Archive Organization'), 'value' => 'ArchiveOrganization'], + ['label' => __('Automotive Business'), 'value' => 'AutomotiveBusiness'], + ['label' => __('Child Care'), 'value' => 'ChildCare'], + ['label' => __('Dentist'), 'value' => 'Dentist'], + ['label' => __('Dry Cleaning Or Laundry'), 'value' => 'DryCleaningOrLaundry'], + ['label' => __('Emergency Service'), 'value' => 'EmergencyService'], + ['label' => __('Employment Agency'), 'value' => 'EmploymentAgency'], + ['label' => __('Entertainment Business'), 'value' => 'EntertainmentBusiness'], + ['label' => __('Financial Service'), 'value' => 'FinancialService'], + ['label' => __('Food Establishment'), 'value' => 'FoodEstablishment'], + ['label' => __('Government Office'), 'value' => 'Government Office'], + ['label' => __('Health And Beauty Business'), 'value' => 'HealthAndBeautyBusiness'], + ['label' => __('Home And Construction Business'), 'value' => 'HomeAndConstructionBusiness'], + ['label' => __('Internet Cafe'), 'value' => 'InternetCafe'], + ['label' => __('Legal Service'), 'value' => 'Legal Service'], + ['label' => __('Library'), 'value' => 'Library'], + ['label' => __('Lodging Business'), 'value' => 'LodgingBusiness'], + ['label' => __('Medical Business'), 'value' => 'MedicalBusiness'], + ['label' => __('Professional Service'), 'value' => 'ProfessionalService'], + ['label' => __('Radio Station'), 'value' => 'RadioStation'], + ['label' => __('Real Estate Agent'), 'value' => 'RealEstateAgent'], + ['label' => __('Recycling Center'), 'value' => 'RecyclingCenter'], + ['label' => __('Self Storage'), 'value' => 'SelfStorage'], + ['label' => __('Shopping Center'), 'value' => 'ShoppingCenter'], + ['label' => __('Sports Activity Location'), 'value' => 'SportsActivityLocation'], + ['label' => __('Television Station'), 'value' => 'TelevisionStation'], + ['label' => __('Tourist Information Center'), 'value' => 'TouristInformationCenter'], + ['label' => __('Travel Agency'), 'value' => 'TravelAgency'], ]; } } From da942e89cae90afc18face30597d3f04eb4290e5 Mon Sep 17 00:00:00 2001 From: giaphn Date: Mon, 28 Mar 2022 16:10:03 +0700 Subject: [PATCH 11/18] - Update Bussiness Type --- Model/Config/Source/BussinessType.php | 61 ++++++++++++++------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/Model/Config/Source/BussinessType.php b/Model/Config/Source/BussinessType.php index 567e9b1..ac6d91a 100644 --- a/Model/Config/Source/BussinessType.php +++ b/Model/Config/Source/BussinessType.php @@ -35,36 +35,37 @@ class BussinessType implements ArrayInterface public function toOptionArray() { return [ - ['label' => __('--Please Select--'), 'value' => 'Store'], - ['label' => __('Animal Shelter'), 'value' => 'AnimalShelter'], - ['label' => __('Archive Organization'), 'value' => 'ArchiveOrganization'], - ['label' => __('Automotive Business'), 'value' => 'AutomotiveBusiness'], - ['label' => __('Child Care'), 'value' => 'ChildCare'], - ['label' => __('Dentist'), 'value' => 'Dentist'], - ['label' => __('Dry Cleaning Or Laundry'), 'value' => 'DryCleaningOrLaundry'], - ['label' => __('Emergency Service'), 'value' => 'EmergencyService'], - ['label' => __('Employment Agency'), 'value' => 'EmploymentAgency'], - ['label' => __('Entertainment Business'), 'value' => 'EntertainmentBusiness'], - ['label' => __('Financial Service'), 'value' => 'FinancialService'], - ['label' => __('Food Establishment'), 'value' => 'FoodEstablishment'], - ['label' => __('Government Office'), 'value' => 'Government Office'], - ['label' => __('Health And Beauty Business'), 'value' => 'HealthAndBeautyBusiness'], - ['label' => __('Home And Construction Business'), 'value' => 'HomeAndConstructionBusiness'], - ['label' => __('Internet Cafe'), 'value' => 'InternetCafe'], - ['label' => __('Legal Service'), 'value' => 'Legal Service'], - ['label' => __('Library'), 'value' => 'Library'], - ['label' => __('Lodging Business'), 'value' => 'LodgingBusiness'], - ['label' => __('Medical Business'), 'value' => 'MedicalBusiness'], - ['label' => __('Professional Service'), 'value' => 'ProfessionalService'], - ['label' => __('Radio Station'), 'value' => 'RadioStation'], - ['label' => __('Real Estate Agent'), 'value' => 'RealEstateAgent'], - ['label' => __('Recycling Center'), 'value' => 'RecyclingCenter'], - ['label' => __('Self Storage'), 'value' => 'SelfStorage'], - ['label' => __('Shopping Center'), 'value' => 'ShoppingCenter'], - ['label' => __('Sports Activity Location'), 'value' => 'SportsActivityLocation'], - ['label' => __('Television Station'), 'value' => 'TelevisionStation'], - ['label' => __('Tourist Information Center'), 'value' => 'TouristInformationCenter'], - ['label' => __('Travel Agency'), 'value' => 'TravelAgency'], + ['label' => __('Local Bussiness'), 'value' => 'LocalBussiness'], + ['label' => __('Auto Parts Store'), 'value' => 'AutoPartsStore'], + ['label' => __('Bike Store'), 'value' => 'BikeStore'], + ['label' => __('Book Store'), 'value' => 'BookStore'], + ['label' => __('Clothing Store'), 'value' => 'ClothingStore'], + ['label' => __('Computer Store'), 'value' => 'ComputerStore'], + ['label' => __('Convenience Store'), 'value' => 'ConvenienceStore'], + ['label' => __('Department Store'), 'value' => 'DepartmentStore'], + ['label' => __('Electronics Store'), 'value' => 'Electronics Store'], + ['label' => __('Florist'), 'value' => 'Florist'], + ['label' => __('Furniture Store'), 'value' => 'FurnitureStore'], + ['label' => __('Garden Store'), 'value' => 'GardenStore'], + ['label' => __('Grocery Store'), 'value' => 'GroceryStore'], + ['label' => __('Hardware Store'), 'value' => 'HardwareStore'], + ['label' => __('Hobby Shop'), 'value' => 'HobbyShop'], + ['label' => __('Home Goods Store'), 'value' => 'HomeGoodsStore'], + ['label' => __('Jewelry Store'), 'value' => 'JewelryStore'], + ['label' => __('Liquor Store'), 'value' => 'LiquorStore'], + ['label' => __('Mens Clothing Store'), 'value' => 'MensClothingStore'], + ['label' => __('Mobile Phone Store'), 'value' => 'MobilePhoneStore'], + ['label' => __('Movie Rental Store'), 'value' => 'MovieRentalStore'], + ['label' => __('Music Store'), 'value' => 'MusicStore'], + ['label' => __('Office Equipment Store'), 'value' => 'OfficeEquipmentStore'], + ['label' => __('Outlet Store'), 'value' => 'OutletStore'], + ['label' => __('Pawn Shop'), 'value' => 'PawnShop'], + ['label' => __('Pet Store'), 'value' => 'PetStore'], + ['label' => __('Shoe Store'), 'value' => 'ShoeStore'], + ['label' => __('Sporting Goods Store'), 'value' => 'SportingGoodsStore'], + ['label' => __('Tire Shop'), 'value' => 'TireShop'], + ['label' => __('Toy Store'), 'value' => 'ToyStore'], + ['label' => __('Wholesale Store'), 'value' => 'WholesaleStore'], ]; } } From 2db28af1a38d56dc3493cc53b1e1cbb2edf158ca Mon Sep 17 00:00:00 2001 From: giaphn Date: Mon, 28 Mar 2022 16:10:44 +0700 Subject: [PATCH 12/18] - Update Bussiness Type --- Model/Config/Source/BussinessType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Config/Source/BussinessType.php b/Model/Config/Source/BussinessType.php index ac6d91a..99bcb50 100644 --- a/Model/Config/Source/BussinessType.php +++ b/Model/Config/Source/BussinessType.php @@ -43,7 +43,7 @@ public function toOptionArray() ['label' => __('Computer Store'), 'value' => 'ComputerStore'], ['label' => __('Convenience Store'), 'value' => 'ConvenienceStore'], ['label' => __('Department Store'), 'value' => 'DepartmentStore'], - ['label' => __('Electronics Store'), 'value' => 'Electronics Store'], + ['label' => __('Electronics Store'), 'value' => 'ElectronicsStore'], ['label' => __('Florist'), 'value' => 'Florist'], ['label' => __('Furniture Store'), 'value' => 'FurnitureStore'], ['label' => __('Garden Store'), 'value' => 'GardenStore'], From 7137bb6506f0d99dbd54372355e96f4371d09b68 Mon Sep 17 00:00:00 2001 From: giaphn Date: Tue, 29 Mar 2022 10:50:55 +0700 Subject: [PATCH 13/18] - Update Bussiness Type --- Model/Config/Source/BussinessType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Config/Source/BussinessType.php b/Model/Config/Source/BussinessType.php index 99bcb50..a90fdb1 100644 --- a/Model/Config/Source/BussinessType.php +++ b/Model/Config/Source/BussinessType.php @@ -35,7 +35,7 @@ class BussinessType implements ArrayInterface public function toOptionArray() { return [ - ['label' => __('Local Bussiness'), 'value' => 'LocalBussiness'], + ['label' => __('Local Business'), 'value' => 'LocalBusiness'], ['label' => __('Auto Parts Store'), 'value' => 'AutoPartsStore'], ['label' => __('Bike Store'), 'value' => 'BikeStore'], ['label' => __('Book Store'), 'value' => 'BookStore'], From 839467a426f1e23e029e559ef1b33c1c1600bac8 Mon Sep 17 00:00:00 2001 From: giaphn Date: Tue, 29 Mar 2022 10:57:22 +0700 Subject: [PATCH 14/18] - Fix typo problem --- Model/Config/Source/{BussinessType.php => BusinessType.php} | 4 ++-- etc/adminhtml/system.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) rename Model/Config/Source/{BussinessType.php => BusinessType.php} (97%) diff --git a/Model/Config/Source/BussinessType.php b/Model/Config/Source/BusinessType.php similarity index 97% rename from Model/Config/Source/BussinessType.php rename to Model/Config/Source/BusinessType.php index a90fdb1..d62d0fc 100644 --- a/Model/Config/Source/BussinessType.php +++ b/Model/Config/Source/BusinessType.php @@ -24,10 +24,10 @@ use Magento\Framework\Option\ArrayInterface; /** - * Class BussinessType + * Class BusinessType * @package Mageplaza\Seo\Model\Config\Source */ -class BussinessType implements ArrayInterface +class BusinessType implements ArrayInterface { /** * @return array diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 1f776ce..3a76c8b 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -128,8 +128,8 @@ - - Mageplaza\Seo\Model\Config\Source\BussinessType + + Mageplaza\Seo\Model\Config\Source\BusinessType 1 From 12c5408db1884f5ccd02e1f3715b7d2772d66222 Mon Sep 17 00:00:00 2001 From: giaphn Date: Tue, 29 Mar 2022 14:32:55 +0700 Subject: [PATCH 15/18] - Update configuration. --- .../{BussinessImage.php => BusinessImage.php} | 6 +- Model/Config/Source/BusinessType.php | 1 + etc/adminhtml/system.xml | 2 +- etc/config.xml | 100 +++++++++--------- 4 files changed, 59 insertions(+), 50 deletions(-) rename Model/Config/Backend/{BussinessImage.php => BusinessImage.php} (92%) diff --git a/Model/Config/Backend/BussinessImage.php b/Model/Config/Backend/BusinessImage.php similarity index 92% rename from Model/Config/Backend/BussinessImage.php rename to Model/Config/Backend/BusinessImage.php index 8e5a407..34426e1 100644 --- a/Model/Config/Backend/BussinessImage.php +++ b/Model/Config/Backend/BusinessImage.php @@ -23,7 +23,11 @@ use Magento\Config\Model\Config\Backend\Image; -class BussinessImage extends Image +/** + * Class BusinessImage + * @package Mageplaza\Seo\Model\Config\Source + */ +class BusinessImage extends Image { /** * The tail part of directory path for uploading diff --git a/Model/Config/Source/BusinessType.php b/Model/Config/Source/BusinessType.php index d62d0fc..e5fba86 100644 --- a/Model/Config/Source/BusinessType.php +++ b/Model/Config/Source/BusinessType.php @@ -35,6 +35,7 @@ class BusinessType implements ArrayInterface public function toOptionArray() { return [ + ['label' => __('Store'), 'value' => 'Store'], ['label' => __('Local Business'), 'value' => 'LocalBusiness'], ['label' => __('Auto Parts Store'), 'value' => 'AutoPartsStore'], ['label' => __('Bike Store'), 'value' => 'BikeStore'], diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml index 3a76c8b..1ba4ff9 100755 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -193,7 +193,7 @@ - Mageplaza\Seo\Model\Config\Backend\BussinessImage + Mageplaza\Seo\Model\Config\Backend\BusinessImage mageplaza/seo 1 diff --git a/etc/config.xml b/etc/config.xml index 2447041..594f562 100755 --- a/etc/config.xml +++ b/etc/config.xml @@ -1,48 +1,52 @@ - - - - - - - 1 - seo-m2 - - - 1 - - 0 - manufacturer - 7days - mpn - sku - - - - - - 1 - 1 - - - - + + + + + + + 1 + seo-m2 + + + 1 + + + 0 + manufacturer + 7days + mpn + sku + + + 0 + Store + + + + + 1 + 1 + + + + From 417aa285692f61d298db3752110706b0222274b9 Mon Sep 17 00:00:00 2001 From: giaphn Date: Tue, 29 Mar 2022 15:15:34 +0700 Subject: [PATCH 16/18] - Update business type --- Model/Config/Source/BusinessType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/Config/Source/BusinessType.php b/Model/Config/Source/BusinessType.php index e5fba86..72be110 100644 --- a/Model/Config/Source/BusinessType.php +++ b/Model/Config/Source/BusinessType.php @@ -45,7 +45,7 @@ public function toOptionArray() ['label' => __('Convenience Store'), 'value' => 'ConvenienceStore'], ['label' => __('Department Store'), 'value' => 'DepartmentStore'], ['label' => __('Electronics Store'), 'value' => 'ElectronicsStore'], - ['label' => __('Florist'), 'value' => 'Florist'], + ['label' => __('Florist Store'), 'value' => 'Florist'], ['label' => __('Furniture Store'), 'value' => 'FurnitureStore'], ['label' => __('Garden Store'), 'value' => 'GardenStore'], ['label' => __('Grocery Store'), 'value' => 'GroceryStore'], From 520a28ac0a4e625ad8c2037cc1ed01174ac52090 Mon Sep 17 00:00:00 2001 From: shox Date: Tue, 21 Jun 2022 15:22:52 +0700 Subject: [PATCH 17/18] - Compatible 244 --- Plugin/SeoRender.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Plugin/SeoRender.php b/Plugin/SeoRender.php index 4a23af7..4bb7341 100755 --- a/Plugin/SeoRender.php +++ b/Plugin/SeoRender.php @@ -367,7 +367,7 @@ public function showProductStructuredData() '@context' => 'http://schema.org/', '@type' => 'Product', 'name' => $currentProduct->getName(), - 'description' => trim(strip_tags($currentProduct->getDescription())), + 'description' => $currentProduct->getDescription() ? trim(strip_tags($currentProduct->getDescription())) : '', 'sku' => $currentProduct->getSku(), 'url' => $currentProduct->getProductUrl(), 'image' => $this->getUrl('pub/media/catalog') . 'product' . $currentProduct->getImage(), @@ -579,11 +579,11 @@ public function getGroupedProductStructuredData($currentProduct, $productStructu $offerData[] = [ '@type' => 'Offer', 'name' => $child->getName(), - 'price' => $this->_priceHelper->currency($child->getPrice(), false), + 'price' => $this->_priceHelper->currency($child->getFinalPrice(), false), 'sku' => $child->getSku(), 'image' => $imageUrl ]; - $childrenPrice[] = $this->_priceHelper->currency($child->getPrice(), false); + $childrenPrice[] = $this->_priceHelper->currency($child->getFinalPrice(), false); } $productStructuredData['offers']['highPrice'] = array_sum($childrenPrice); @@ -611,9 +611,9 @@ public function getBundleProductStructuredData($currentProduct, $productStructur { $productStructuredData['offers']['@type'] = 'AggregateOffer'; try { - $productStructuredData['offers']['highPrice'] = $currentProduct->getPriceInfo()->getPrice('regular_price') + $productStructuredData['offers']['highPrice'] = $currentProduct->getPriceInfo()->getPrice('final_price') ->getMaximalPrice()->getValue(); - $productStructuredData['offers']['lowPrice'] = $currentProduct->getPriceInfo()->getPrice('regular_price') + $productStructuredData['offers']['lowPrice'] = $currentProduct->getPriceInfo()->getPrice('final_price') ->getMinimalPrice()->getValue(); } catch (Exception $exception) { $productStructuredData['offers']['highPrice'] = 0; From 1a80eaf82fc9f93dfb93062611cdd3728347252a Mon Sep 17 00:00:00 2001 From: Brian Date: Fri, 24 Jun 2022 16:07:50 +0700 Subject: [PATCH 18/18] Clean code --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 6aabfd4..4cafd2c 100644 --- a/composer.json +++ b/composer.json @@ -2,10 +2,10 @@ "name": "mageplaza/magento-2-seo-extension", "description": "Magento 2 SEO extension", "require": { - "mageplaza/module-core": "^1.4.5" + "mageplaza/module-core": "^1.4.12" }, "type": "magento2-module", - "version": "4.1.5", + "version": "4.2.0", "license": "proprietary", "keywords": [ "magento 2",