Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #58 from Yoast/feature/seo-attribute-group-code-se…
Browse files Browse the repository at this point in the history
…tting

Feature/seo attribute group code setting
  • Loading branch information
vincenthornikx authored Jan 5, 2018
2 parents 993dff7 + 9db54d1 commit 2da8c3e
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 48 deletions.
4 changes: 0 additions & 4 deletions Block/Adminhtml/YoastBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ protected function _construct()
{
$this->setTemplate('MaxServ_YoastSeo::yoastbox.phtml');

if (!$this->getNameInLayout()) {
$this->setNameInLayout('maxserv_yoast_block');
}

parent::_construct();
}

Expand Down
70 changes: 62 additions & 8 deletions Ui/Catalog/DataProvider/Product/Form/Modifier/YoastSeo.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\Stdlib\ArrayManager;
use Magento\Framework\View\LayoutInterface;
use Magento\Ui\Component\Container;
use MaxServ\YoastSeo\Helper\ImageHelper;

class YoastSeo extends AbstractModifier
Expand All @@ -45,21 +47,40 @@ class YoastSeo extends AbstractModifier
*/
protected $imageHelper;

/**
* @var LayoutInterface
*/
protected $layout;

/**
* @var bool
*/
protected $moduleIsDisabled = false;

/**
* @var string
*/
protected $seoAttributeGroupCode;

/**
* @param ScopeConfigInterface $scopeConfig
* @param ArrayManager $arrayManager
* @param ImageHelper $imageHelper
* @param LayoutInterface $layout
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
ArrayManager $arrayManager,
ImageHelper $imageHelper
ImageHelper $imageHelper,
LayoutInterface $layout
) {
$this->scopeConfig = $scopeConfig;
$this->arrayManager = $arrayManager;
$this->imageHelper = $imageHelper;
$this->layout = $layout;

$this->moduleIsDisabled = (bool)$this->scopeConfig->getValue('advanced/modules_disable_output/MaxServ_YoastSeo');
$this->seoAttributeGroupCode = (string)$this->scopeConfig->getValue('yoastseo/advanced/product_seo_attribute_group_code');
}

/**
Expand Down Expand Up @@ -142,13 +163,46 @@ protected function setYoastFieldClasses(&$meta)
}
}

$meta['search-engine-optimization']['arguments']['data']['config']['label'] = __('Yoast SEO');
$meta['search-engine-optimization']['children']['container_url_key']['children']['url_key']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-urlKey';
$meta['search-engine-optimization']['children']['container_meta_title']['children']['meta_title']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-metaTitle hidden';
$meta['search-engine-optimization']['children']['container_meta_description']['children']['meta_description']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-metaDescription hidden';
$meta['search-engine-optimization']['children']['container_meta_keyword']['children']['meta_keyword']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-metaKeywords';
$meta['search-engine-optimization']['children']['container_focus_keyword']['children']['focus_keyword']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-focusKeyword';
$meta['search-engine-optimization']['children']['container_yoast_robots_instructions']['children']['yoast_robots_instructions']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-robotsInstructions';
$groupCode = $this->seoAttributeGroupCode;

$meta[$groupCode]['arguments']['data']['config']['label'] = __('Yoast SEO');
$meta[$groupCode]['children']['container_url_key']['children']['url_key']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-urlKey';
$meta[$groupCode]['children']['container_meta_title']['children']['meta_title']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-metaTitle hidden';
$meta[$groupCode]['children']['container_meta_description']['children']['meta_description']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-metaDescription hidden';
$meta[$groupCode]['children']['container_meta_keyword']['children']['meta_keyword']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-metaKeywords';
$meta[$groupCode]['children']['container_focus_keyword']['children']['focus_keyword']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-focusKeyword';
$meta[$groupCode]['children']['container_yoast_robots_instructions']['children']['yoast_robots_instructions']['arguments']['data']['config']['additionalClasses'] = 'yoastBox-robotsInstructions';

$meta[$groupCode]['children']['container_yoastBox_block'] = [
'arguments' => [
'data' => [
'config' => [
'formElement' => Container::NAME,
'componentType' => Container::NAME,
'breakLine' => false,
'label' => 'Yoast',
'required' => true,
'sortOrder' => 100
]
]
],
'children' => [
'yoastBox_block' => [
'arguments' => [
'data' => [
'config' => [
'label' => null,
'formElement' => Container::NAME,
'componentType' => Container::NAME,
'template' => 'ui/form/components/complex',
'content' => $this->layout->createBlock('MaxServ\YoastSeo\Block\Adminhtml\YoastBox')->toHtml(),
'sortOrder' => 10
]
]
]
]
]
];

// facebook fieldset
$meta['yoast-facebook']['arguments']['data']['config']['label'] = '';
Expand Down
2 changes: 1 addition & 1 deletion etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<argument name="modifiers" xsi:type="array">
<item name="yoastseo" xsi:type="array">
<item name="class" xsi:type="string">MaxServ\YoastSeo\Ui\Catalog\DataProvider\Product\Form\Modifier\YoastSeo</item>
<item name="sortOrder" xsi:type="number">130</item>
<item name="sortOrder" xsi:type="number">100000</item>
</item>
</argument>
</arguments>
Expand Down
6 changes: 6 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@
<backend_model>MaxServ\YoastSeo\Model\Adminhtml\System\Config\Backend\AnalysisTemplates</backend_model>
</field>
</group>
<group id="advanced" translate="true" sortOrder="50" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Advanced Configuration</label>
<field id="product_seo_attribute_group_code" type="text" translate="label" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Product SEO attribute group code</label>
</field>
</group>
</section>
</system>
</config>
9 changes: 9 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<yoastseo>
<advanced>
<product_seo_attribute_group_code>search-engine-optimization</product_seo_attribute_group_code>
</advanced>
</yoastseo>
</default>
</config>
35 changes: 0 additions & 35 deletions view/adminhtml/ui_component/product_form.xml

This file was deleted.

0 comments on commit 2da8c3e

Please sign in to comment.