Skip to content

Commit

Permalink
Merge pull request #107 from mageplaza/2.3-develop
Browse files Browse the repository at this point in the history
2.3-develop
  • Loading branch information
Shinichi69 authored Jul 7, 2021
2 parents db5b54d + 1f54879 commit c48b008
Show file tree
Hide file tree
Showing 15 changed files with 594 additions and 536 deletions.
4 changes: 2 additions & 2 deletions Block/Adminhtml/SeoChecker/CheckButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public function __construct(Data $helper)
*/
public function getButtonData()
{
if (!$this->helper->isEnabled()) {
if (!$this->helper->isEnabled($this->helper->getStoreId())) {
return [];
}

return [
'label' => __('Check On-page'),
'class' => 'action-secondary save',
'on_click' => 'jQuery("#mageplaza-seo-form").attr("action", "http://seo.mageplaza.com").submit();',
'on_click' => 'jQuery("#mageplaza-seo-form").attr("action", "https://seo.mageplaza.com").submit();',
'sort_order' => 85
];
}
Expand Down
14 changes: 5 additions & 9 deletions Block/Adminhtml/SeoChecker/CheckForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
use Magento\Cms\Model\PageFactory;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Json\Helper\Data as JsonData;
use Magento\Framework\Url;
use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;
use Magento\Sitemap\Model\ResourceModel\Sitemap\Collection;
use Magento\Sitemap\Model\ResourceModel\Sitemap\CollectionFactory;
use Mageplaza\Seo\Helper\Data as SeoHelperData;
Expand Down Expand Up @@ -90,8 +90,7 @@ class CheckForm extends Template
/**
* CheckForm constructor.
*
* @param Template\Context $context
* @param Url $url
* @param Context $context
* @param UrlBuilder $cmsUrl
* @param PageFactory $cmsPageFactory
* @param CollectionFactory $sitemapCollection
Expand All @@ -103,8 +102,7 @@ class CheckForm extends Template
* @param array $data
*/
public function __construct(
Template\Context $context,
Url $url,
Context $context,
UrlBuilder $cmsUrl,
PageFactory $cmsPageFactory,
CollectionFactory $sitemapCollection,
Expand Down Expand Up @@ -137,14 +135,13 @@ public function getLink()
{
$id = $this->_request->getParam('id');
$storeCode = $this->_storeManager->getStore()->getCode();
$storeId = $this->_storeManager->getStore()->getId();
$storeId = $this->_request->getParam('store');
$actionName = $this->_request->getFullActionName();
if ($storeId === 0) {
if ($storeId === 0 || $storeId === null) {
$defaultStore = $this->_storeManager->getDefaultStoreView();
$storeId = $defaultStore->getId();
$storeCode = $defaultStore->getCode();
}

switch ($actionName) {
case 'catalog_product_edit':
$urlModel = $this->productRepository->getById($id)->getUrlModel();
Expand All @@ -166,7 +163,6 @@ public function getLink()
default:
$url = '';
}

return $url;
}

Expand Down
25 changes: 21 additions & 4 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

namespace Mageplaza\Seo\Helper;

use Exception;
use Magento\Theme\Block\Html\Header\Logo;
use Mageplaza\Core\Helper\AbstractData as CoreHelper;

Expand All @@ -33,7 +34,7 @@ class Data extends CoreHelper
const CONFIG_MODULE_PATH = 'seo';

/**
* @param $code
* @param string $code
* @param null $storeId
*
* @return mixed
Expand All @@ -46,7 +47,7 @@ public function getMetaConfig($code, $storeId = null)
}

/**
* @param $code
* @param string $code
* @param null $storeId
*
* @return mixed
Expand All @@ -59,7 +60,7 @@ public function getVerficationConfig($code, $storeId = null)
}

/**
* @param $code
* @param string $code
* @param null $storeId
*
* @return mixed
Expand Down Expand Up @@ -113,7 +114,7 @@ public function getDuplicateConfig($code = null, $storeId = null)
/**
* Create structure data script
*
* @param $data
* @param array $data
* @param string $prefixComment
* @param string $subfixComment
*
Expand Down Expand Up @@ -142,4 +143,20 @@ public function getLogo()

return $logo->getLogoSrc();
}

/**
* Get Store Id
*
* @return int|null
*/
public function getStoreId()
{
try {
$storeId = $this->storeManager->getStore()->getId();
} catch (Exception $e) {
$storeId = null;
}

return $storeId;
}
}
2 changes: 1 addition & 1 deletion Observer/RemoveSchemaObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function execute(Observer $observer)
{
$layout = $observer->getData('layout');

if (!$this->_helperData->isEnabled()) {
if (!$this->_helperData->isEnabled($this->_helperData->getStoreId())) {
return $this;
}

Expand Down
8 changes: 4 additions & 4 deletions Plugin/Helper/CanUseCanonicalTagForCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ class CanUseCanonicalTagForCategories
*
* @param HelperData $helper
*/
function __construct(HelperData $helper)
public function __construct(HelperData $helper)
{
$this->_helper = $helper;
}

/**
* @param Category $category
* @param $result
* @param string $result
*
* @return mixed
*/
public function afterCanUseCanonicalTag(Category $category, $result)
{
if ($this->_helper->isEnabled()) {
return $this->_helper->getDuplicateConfig('category_canonical_tag');
if ($this->_helper->isEnabled($this->_helper->getStoreId())) {
return $this->_helper->getDuplicateConfig('category_canonical_tag', $this->_helper->getStoreId());
}

return $result;
Expand Down
8 changes: 4 additions & 4 deletions Plugin/Helper/CanUseCanonicalTagForProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ class CanUseCanonicalTagForProducts
*
* @param HelperData $helper
*/
function __construct(HelperData $helper)
public function __construct(HelperData $helper)
{
$this->_helper = $helper;
}

/**
* @param Product $product
* @param $result
* @param string $result
*
* @return mixed
*/
public function afterCanUseCanonicalTag(Product $product, $result)
{
if ($this->_helper->isEnabled()) {
return $this->_helper->getDuplicateConfig('product_canonical_tag');
if ($this->_helper->isEnabled($this->_helper->getStoreId())) {
return $this->_helper->getDuplicateConfig('product_canonical_tag', $this->_helper->getStoreId());
}

return $result;
Expand Down
2 changes: 1 addition & 1 deletion Plugin/RemoveReview.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(HelperData $helperData)
*/
public function afterGetReviewsSummaryHtml(ReviewRenderer $subject, $result)
{
if (!$this->_helperData->isEnabled()) {
if (!$this->_helperData->isEnabled($this->_helperData->getStoreId())) {
return $result;
}

Expand Down
Loading

0 comments on commit c48b008

Please sign in to comment.