From 67f00c60167962aaa3ca0fdd3e589fa452b4e2fc Mon Sep 17 00:00:00 2001 From: justin Date: Mon, 28 Nov 2022 10:12:42 +0700 Subject: [PATCH 1/4] Fix compa magento 2.4.5 p1 --- Plugin/SeoRender.php | 48 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/Plugin/SeoRender.php b/Plugin/SeoRender.php index 73000eb..4a01164 100755 --- a/Plugin/SeoRender.php +++ b/Plugin/SeoRender.php @@ -55,6 +55,7 @@ use Magento\InventoryApi\Api\GetSourceItemsBySkuInterface as SourceItems; use Magento\InventorySales\Model\ResourceModel\GetAssignedStockIdForWebsite as AssignedStock; use Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku as SalableQuantity; +use Magento\Catalog\Helper\Image as ImageHelper; /** * Class SeoRender @@ -188,6 +189,11 @@ class SeoRender */ protected $salableQuantity; + /** + * @var ImageHelper + */ + protected $imageHelper; + /** * SeoRender constructor. * @@ -215,6 +221,7 @@ class SeoRender * @param SourceItems $sourceItemsBySku * @param AssignedStock $assignedStock * @param SalableQuantity $salableQuantity + * @param ImageHelper $imageHelper */ public function __construct( PageConfig $pageConfig, @@ -240,7 +247,8 @@ public function __construct( CollectionFactory $collectionFactory, SourceItems $sourceItemsBySku, AssignedStock $assignedStock, - SalableQuantity $salableQuantity + SalableQuantity $salableQuantity, + ImageHelper $imageHelper ) { $this->pageConfig = $pageConfig; $this->request = $request; @@ -266,6 +274,7 @@ public function __construct( $this->sourceItemsBySku = $sourceItemsBySku; $this->assignedStock = $assignedStock; $this->salableQuantity = $salableQuantity; + $this->imageHelper = $imageHelper; } /** @@ -421,6 +430,12 @@ public function showProductStructuredData() } $modelName = $this->helperData->getRichsnippetsConfig('model_name'); + if($currentProduct->getImage()) { + $imageUrl = $this->getUrl('pub/media/catalog') . 'product' . $currentProduct->getImage(); + }else { + $imageUrl = $this->imageHelper->init($currentProduct,'product_base_image')->getUrl(); + } + $productStructuredData = [ '@context' => 'http://schema.org/', '@type' => 'Product', @@ -428,7 +443,7 @@ public function showProductStructuredData() 'description' => $currentProduct->getDescription() ? trim(strip_tags($currentProduct->getDescription())) : '', 'sku' => $currentProduct->getSku(), 'url' => $currentProduct->getProductUrl(), - 'image' => $this->getUrl('/media/catalog') . 'product' . $currentProduct->getImage(), + 'image' => $imageUrl, 'offers' => [ '@type' => 'Offer', 'priceCurrency' => $this->_storeManager->getStore()->getCurrentCurrencyCode(), @@ -504,6 +519,8 @@ public function showProductStructuredData() )->addEntityFilter( 'product', $product->getId() + )->addStoreFilter( + $this->_storeManager->getStore()->getId() )->addRateVotes()->setDateOrder(); if ($collection->getSize()) { foreach ($collection as $review) { @@ -631,8 +648,13 @@ public function getGroupedProductStructuredData($currentProduct, $productStructu $typeInstance = $currentProduct->getTypeInstance(); $childProductCollection = $typeInstance->getAssociatedProducts($currentProduct); foreach ($childProductCollection as $child) { - $imageUrl = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) - . 'catalog/product' . $child->getImage(); + + if($child->getImage()) { + $imageUrl = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) + . 'catalog/product' . $child->getImage(); + }else { + $imageUrl = $this->imageHelper->init($child,'product_base_image')->getUrl(); + } $offerData[] = [ '@type' => 'Offer', @@ -685,9 +707,12 @@ public function getBundleProductStructuredData($currentProduct, $productStructur $currentProduct ); foreach ($childProductCollection as $child) { - $imageUrl = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) - . 'catalog/product' . $child->getImage(); - + if($child->getImage()) { + $imageUrl = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) + . 'catalog/product' . $child->getImage(); + }else { + $imageUrl = $this->imageHelper->init($child,'product_base_image')->getUrl(); + } $offerData[] = [ '@type' => 'Offer', 'name' => $child->getName(), @@ -755,8 +780,13 @@ public function getConfigurableProductStructuredData($currentProduct, $productSt ->addAttributeToSelect('*'); $allChildPrices = []; foreach ($childProductCollection as $child) { - $imageUrl = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) - . 'catalog/product' . $child->getImage(); + + if($child->getImage()) { + $imageUrl = $this->_storeManager->getStore()->getBaseUrl(UrlInterface::URL_TYPE_MEDIA) + . 'catalog/product' . $child->getImage(); + }else { + $imageUrl = $this->imageHelper->init($child,'product_base_image')->getUrl(); + } $childPrice = $this->_priceHelper->currency($child->getPrice(), false); $allChildPrices[] = $childPrice; $offerData[] = [ From ba868db927e0d866a5341bc62844265620cb1aa8 Mon Sep 17 00:00:00 2001 From: Onesh Date: Mon, 13 Feb 2023 16:54:03 +0700 Subject: [PATCH 2/4] Update translate --- i18n/en_US.csv | 169 ++++++++++++++++++++++++++++++------------------- 1 file changed, 104 insertions(+), 65 deletions(-) diff --git a/i18n/en_US.csv b/i18n/en_US.csv index 621c444..f08059d 100644 --- a/i18n/en_US.csv +++ b/i18n/en_US.csv @@ -1,65 +1,104 @@ -"Check On-page","Check On-page" -gtin8,gtin8 -gtin13,gtin13 -gtin14,gtin14 -mpn,mpn -None,None -"+7 days","+7 days" -"+30 days","+30 days" -"+60 days","+60 days" -"+1 year","+1 year" -Custom,Custom -"Can not add structured data","Can not add structured data" -SEO,SEO -General,General -Enable,Enable -"Duplicate Content","Duplicate Content" -"Use Canonical Link Meta Tag For Categories","Use Canonical Link Meta Tag For Categories" -"Avoid duplicate content.","Avoid duplicate content." -"Use Canonical Link Meta Tag For Products","Use Canonical Link Meta Tag For Products" -"Structured Data","Structured Data" -"Enable Product Structured Data","Enable Product Structured Data" -"Disable this feature if your theme or module implements it's own product snippets. Learn more","Disable this feature if your theme or module implements it's own product snippets. Learn more" -Brand,Brand -"Default Aggregate Rating Value","Default Aggregate Rating Value" -"To avoid warning message, you can set default value in case of no Aggregate Rating/Review.","To avoid warning message, you can set default value in case of no Aggregate Rating/Review." -"Default Rating Value","Default Rating Value" -"Default Review Count","Default Review Count" -"Default Review Author","Default Review Author" -"Default Price Valid Until","Default Price Valid Until" -"Select Specific Day","Select Specific Day" -"Model Field Name","Model Field Name" -"Learn more here","Learn more here" -"Model Value","Model Value" -"Recommend field: sku, barcode","Recommend field: sku, barcode" -"Enable Sitelinks Searchbox","Enable Sitelinks Searchbox" -"Learn more here","Learn more here" -"Business information","Business information" -"Enable Business information","Enable Business information" -"Learn more here","Learn more here" -"Business Name","Business Name" -"Customer Service Phone","Customer Service Phone" -"Customer Service Contact Option","Customer Service Contact Option" -"Customer Service Area Serve","Customer Service Area Serve" -"Technical Support Phone","Technical Support Phone" -"Technical Support Contact Option","Technical Support Contact Option" -"Technical Support Area Serve","Technical Support Area Serve" -"Sales Service Phone","Sales Service Phone" -"Sales Contact Option","Sales Contact Option" -"Sales Area Serve","Sales Area Serve" -"Social Profiles","Social Profiles" -Facebook,Facebook -Twitter,Twitter -Google+,Google+ -Instagram,Instagram -YouTube,YouTube -LinkedIn,LinkedIn -Myspace,Myspace -Pinterest,Pinterest -SoundCloud,SoundCloud -Tumblr,Tumblr -Verifications,Verifications -"Google Search Console","Google Search Console" -"Enter verification code, it will be added into tag","Enter verification code, it will be added into tag" -"Bing Webmaster Tools","Bing Webmaster Tools" -"Yandex Webmaster Tools","Yandex Webmaster Tools" +"PageSpeed Insight","PageSpeed Insight" +Store,Store +"Local Business","Local Business" +"Auto Parts Store","Auto Parts Store" +"Bike Store","Bike Store" +"Book Store","Book Store" +"Clothing Store","Clothing Store" +"Computer Store","Computer Store" +"Convenience Store","Convenience Store" +"Department Store","Department Store" +"Electronics Store","Electronics Store" +"Florist Store","Florist Store" +"Furniture Store","Furniture Store" +"Garden Store","Garden Store" +"Grocery Store","Grocery Store" +"Hardware Store","Hardware Store" +"Hobby Shop","Hobby Shop" +"Home Goods Store","Home Goods Store" +"Jewelry Store","Jewelry Store" +"Liquor Store","Liquor Store" +"Mens Clothing Store","Mens Clothing Store" +"Mobile Phone Store","Mobile Phone Store" +"Movie Rental Store","Movie Rental Store" +"Music Store","Music Store" +"Office Equipment Store","Office Equipment Store" +"Outlet Store","Outlet Store" +"Pawn Shop","Pawn Shop" +"Pet Store","Pet Store" +"Shoe Store","Shoe Store" +"Sporting Goods Store","Sporting Goods Store" +"Tire Shop","Tire Shop" +"Toy Store","Toy Store" +"Wholesale Store","Wholesale Store" +gtin8,gtin8 +gtin13,gtin13 +gtin14,gtin14 +mpn,mpn +None,None +"+7 days","+7 days" +"+30 days","+30 days" +"+60 days","+60 days" +"+1 year","+1 year" +Custom,Custom +"Can not add structured data","Can not add structured data" +"Please enter a valid phone number","Please enter a valid phone number" +SEO,SEO +General,General +Enable,Enable +"Duplicate Content","Duplicate Content" +"Use Canonical Link Meta Tag For Categories","Use Canonical Link Meta Tag For Categories" +"Avoid duplicate content.","Avoid duplicate content." +"Use Canonical Link Meta Tag For Products","Use Canonical Link Meta Tag For Products" +"Structured Data","Structured Data" +"Enable Product Structured Data","Enable Product Structured Data" +"Disable this feature if your theme or module implements it's own product snippets. Learn more","Disable this feature if your theme or module implements it's own product snippets. Learn more" +Brand,Brand +"Default Price Valid Until","Default Price Valid Until" +"Select Specific Day","Select Specific Day" +"Model Field Name","Model Field Name" +"Learn more here","Learn more here" +"Model Value","Model Value" +"Recommend field: sku, barcode","Recommend field: sku, barcode" +"Enable Sitelinks Searchbox","Enable Sitelinks Searchbox" +"Learn more here","Learn more here" +"Business information","Business information" +"Enable Business Information","Enable Business Information" +"Learn more here","Learn more here" +"Business Name","Business Name" +"Business Type","Business Type" +"Customer Service Phone","Customer Service Phone" +"Customer Service Contact Option","Customer Service Contact Option" +"Customer Service Area Serve","Customer Service Area Serve" +"Technical Support Phone","Technical Support Phone" +"Technical Support Contact Option","Technical Support Contact Option" +"Technical Support Area Serve","Technical Support Area Serve" +"Sales Service Phone","Sales Service Phone" +"Sales Contact Option","Sales Contact Option" +"Sales Area Serve","Sales Area Serve" +Image,Image +"Image URL","Image URL" +"Street Address","Street Address" +City,City +State/Province,State/Province +"Zip/Postal Code","Zip/Postal Code" +Email,Email +Fax,Fax +"Price Range","Price Range" +Description,Description +"Social Profiles","Social Profiles" +Facebook,Facebook +Twitter,Twitter +Google+,Google+ +Instagram,Instagram +YouTube,YouTube +LinkedIn,LinkedIn +Myspace,Myspace +Pinterest,Pinterest +SoundCloud,SoundCloud +Tumblr,Tumblr +Verifications,Verifications +"Google Search Console","Google Search Console" +"Enter verification code, it will be added into tag","Enter verification code, it will be added into tag" +"Bing Webmaster Tools","Bing Webmaster Tools" +"Yandex Webmaster Tools","Yandex Webmaster Tools" From 78e824a182557491abe7f2371d6ff89ff1d7d7c3 Mon Sep 17 00:00:00 2001 From: Onesh Date: Mon, 13 Feb 2023 16:56:27 +0700 Subject: [PATCH 3/4] Clean code --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e621759..7680cd3 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.5.0" + "mageplaza/module-core": "^1.5.1" }, "type": "magento2-module", - "version": "4.2.1", + "version": "4.2.2", "license": "proprietary", "keywords": [ "magento 2", From eeeffdf0d6857b97246418dc241264e53a10b2e3 Mon Sep 17 00:00:00 2001 From: Onesh Date: Mon, 13 Feb 2023 16:59:00 +0700 Subject: [PATCH 4/4] Clean code --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7680cd3..3df9db7 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "mageplaza/magento-2-seo-extension", "description": "Magento 2 SEO extension", "require": { - "mageplaza/module-core": "^1.5.1" + "mageplaza/module-core": "^1.5.2" }, "type": "magento2-module", "version": "4.2.2",