Skip to content

Commit

Permalink
Merge branch 'main' of github.com:opengento/magento2-better-bo into f…
Browse files Browse the repository at this point in the history
…eature/delete-endpoint
  • Loading branch information
THOMASPH2M committed Nov 9, 2024
2 parents 1c0dae6 + fbf269c commit a8a1054
Show file tree
Hide file tree
Showing 15 changed files with 531 additions and 157,941 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ jobs:
static:
name: M2 Coding Standard
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version:
- "8.1"
steps:
- uses: actions/checkout@v2
- uses: extdn/github-actions-m2/magento-coding-standard@master
- uses: extdn/github-actions-m2/magento-coding-standard/8.1@master
24 changes: 12 additions & 12 deletions Plugin/ProductEavDataProviderPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Magento\Store\Model\StoreManagerInterface;
use Opengento\BetterBo\Model\Config;
use Psr\Log\LoggerInterface;
use Magento\Store\Model\Store;

/**
* @property StoreInterface[] $stores
Expand Down Expand Up @@ -45,29 +46,28 @@ public function __construct(
public function afterSetupAttributeMeta(Eav $subject, array $result): array
{
$storeSvg = "<svg stroke='currentColor' fill='currentColor' stroke-width='0' viewBox='0 0 616 512' height='200px' width='200px' xmlns='http://www.w3.org/2000/svg'><path d='M602 118.6L537.1 15C531.3 5.7 521 0 510 0H106C95 0 84.7 5.7 78.9 15L14 118.6c-33.5 53.5-3.8 127.9 58.8 136.4 4.5.6 9.1.9 13.7.9 29.6 0 55.8-13 73.8-33.1 18 20.1 44.3 33.1 73.8 33.1 29.6 0 55.8-13 73.8-33.1 18 20.1 44.3 33.1 73.8 33.1 29.6 0 55.8-13 73.8-33.1 18.1 20.1 44.3 33.1 73.8 33.1 4.7 0 9.2-.3 13.7-.9 62.8-8.4 92.6-82.8 59-136.4zM529.5 288c-10 0-19.9-1.5-29.5-3.8V384H116v-99.8c-9.6 2.2-19.5 3.8-29.5 3.8-6 0-12.1-.4-18-1.2-5.6-.8-11.1-2.1-16.4-3.6V480c0 17.7 14.3 32 32 32h448c17.7 0 32-14.3 32-32V283.2c-5.4 1.6-10.8 2.9-16.4 3.6-6.1.8-12.1 1.2-18.2 1.2z'></path></svg>";
if (!isset($result['arguments']['data']['config']['code'])
|| $result['arguments']['data']['config']['globalScope']
|| !\in_array(
$result['arguments']['data']['config']['dataType'],
$this->betterBoConfig->getAttributesFieldsType(),
true
)
) {

$config = $result['arguments']['data']['config'] ?? null;
if (!$config || $config['globalScope'] || !\in_array($config['dataType'], $this->betterBoConfig->getAttributesFieldsType(), true)) {
return $result;
}

$attributeCode = $result['arguments']['data']['config']['code'];
$attributeCode = $config['code'];
$product = $this->registry->registry('current_product');

if (!$product || !$product->getId()) {
return $result;
}

$adminStoreViewId = \Magento\Store\Model\Store::DEFAULT_STORE_ID;
$adminStoreViewId = Store::DEFAULT_STORE_ID;
$currentStoreViewId = $this->storeManager->getStore()->getId();

if ((int) $currentStoreViewId === (int) $adminStoreViewId) {
$result['arguments']['data']['config']['storebtn'] = '<button class=\'btn-store-view\' data-attribute-code=\'' . $attributeCode . '\'>' . $storeSvg . '</button>';
if ((int)$currentStoreViewId === (int)$adminStoreViewId && !$config['globalScope']) {
$result['arguments']['data']['config']['storebtn'] = sprintf(
"<button class='btn-store-view' data-attribute-code='%s'>%s</button>",
$attributeCode,
$storeSvg
);
}

return $result;
Expand Down
6 changes: 5 additions & 1 deletion etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@
<tab>opengento</tab>
<resource>Opengento_BetterBo::system_config</resource>
<group id="general" translate="label" sortOrder="0" type="text" showInDefault="1">
<label>General</label>
<label>General</label>
<field id="attributes_fields_type" sortOrder="10" type="multiselect" showInDefault="1">
<label>Attributes fields type</label>
<source_model>Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype</source_model>
</field>
<field id="tinymce_api_key" translate="label" type="text" sortOrder="20" showInDefault="1">
<label>TinyMCE API Key</label>
<comment>Enter your TinyMCE API key here</comment>
</field>
</group>
</section>
</system>
Expand Down
Loading

0 comments on commit a8a1054

Please sign in to comment.