-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Renen Donkers
committed
Oct 15, 2023
0 parents
commit d491849
Showing
7 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
/** | ||
* Copyright © LotsofPixels.io, Inc. All rights reserved. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace LotsofPixels\CategoryBottomText\Setup\Patch\Data; | ||
|
||
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface; | ||
use Magento\Eav\Setup\EavSetup; | ||
use Magento\Eav\Setup\EavSetupFactory; | ||
use Magento\Framework\Setup\ModuleDataSetupInterface; | ||
use Magento\Framework\Setup\Patch\DataPatchInterface; | ||
use Magento\Catalog\Model\Category; | ||
|
||
/** | ||
* | ||
*/ | ||
class bottomdesciptionAttribute implements DataPatchInterface { | ||
|
||
/** | ||
* @var ModuleDataSetupInterface | ||
*/ | ||
private $moduleDataSetup; | ||
|
||
/** | ||
* @var EavSetupFactory | ||
*/ | ||
private $eavSetupFactory; | ||
/** | ||
* @param ModuleDataSetupInterface $moduleDataSetup | ||
* @param EavSetupFactory $eavSetupFactory | ||
*/ | ||
public function __construct( | ||
ModuleDataSetupInterface $moduleDataSetup, | ||
EavSetupFactory $eavSetupFactory | ||
) { | ||
$this->moduleDataSetup = $moduleDataSetup; | ||
$this->eavSetupFactory = $eavSetupFactory; | ||
} | ||
|
||
/** | ||
* @return void | ||
* @throws \Magento\Framework\Exception\LocalizedException | ||
* @throws \Magento\Framework\Validator\ValidateException | ||
*/ | ||
public function apply() { | ||
/** @var EavSetup $eavSetup */ | ||
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]); | ||
$eavSetup->addAttribute(Category::ENTITY, 'bottom_description', [ | ||
'type' => 'text', | ||
'label' => 'Description', | ||
'input' => 'textarea', | ||
'required' => false, | ||
'sort_order' => 4, | ||
'global' => ScopedAttributeInterface::SCOPE_STORE, | ||
'wysiwyg_enabled' => true, | ||
'is_html_allowed_on_front' => true, | ||
'group' => 'General Information', | ||
]); | ||
} | ||
|
||
/** | ||
* @return array|string[] | ||
*/ | ||
public static function getDependencies() | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function revert() | ||
{ | ||
} | ||
|
||
/** | ||
* @return array|string[] | ||
*/ | ||
public function getAliases() | ||
{ | ||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"name": "lotsofpixels/module-categorybottomtext", | ||
"version": "1.0.0", | ||
"description": "Adds a text field at the bottom of the category pagen for SEO purposes", | ||
"type": "magento2-module", | ||
"require": { | ||
"magento/framework": "*" | ||
}, | ||
"license": [ | ||
"Proprietary" | ||
], | ||
"autoload": { | ||
"files": [ | ||
"registration.php" | ||
], | ||
"psr-4": { | ||
"Lotsofpixels\\CategoryBottomText\\": "" | ||
} | ||
}, | ||
"author": "Rene Donkers", | ||
"createAt": "01-10-2023", | ||
"homepage": "Lotsofpixels.io" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © LotsofPixels.io, Inc. All rights reserved. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> | ||
<module name="Lotsofpixels_CategoryBottomText"/> | ||
</config> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
use Magento\Framework\Component\ComponentRegistrar; | ||
|
||
ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Lotsofpixels_CategoryBottomText', __DIR__); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" ?> | ||
<!-- | ||
/** | ||
* Copyright © LotsofPixels.io, Inc. All rights reserved. | ||
*/ | ||
--> | ||
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> | ||
<fieldset name="content"> | ||
<field name="bottom_description" template="ui/form/field" sortOrder="60" formElement="wysiwyg"> | ||
<argument name="data" xsi:type="array"> | ||
<item name="config" xsi:type="array"> | ||
<item name="wysiwygConfigData" xsi:type="array"> | ||
<item name="height" xsi:type="string">100px</item> | ||
<item name="add_variables" xsi:type="boolean">false</item> | ||
<item name="add_widgets" xsi:type="boolean">false</item> | ||
<item name="add_images" xsi:type="boolean">true</item> | ||
<item name="add_directives" xsi:type="boolean">true</item> | ||
</item> | ||
<item name="source" xsi:type="string">category</item> | ||
</item> | ||
</argument> | ||
<settings> | ||
<label translate="true">Bottom Description</label> | ||
<dataScope>bottom_description</dataScope> | ||
</settings> | ||
<formElements> | ||
<wysiwyg class="Magento\Catalog\Ui\Component\Category\Form\Element\Wysiwyg"> | ||
<settings> | ||
<rows>8</rows> | ||
<wysiwyg>true</wysiwyg> | ||
</settings> | ||
</wysiwyg> | ||
</formElements> | ||
</field> | ||
</fieldset> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © LotsofPixels.io, Inc. All rights reserved. | ||
*/ | ||
--> | ||
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> | ||
<body> | ||
<referenceContainer name="content"> | ||
<block class="Magento\Catalog\Block\Category\View" name="bottom.description" template="Lotsofpixels_CategoryBottomText::product/list/bottom_description.phtml" after="-" /> | ||
</referenceContainer> | ||
</body> | ||
</page> |
9 changes: 9 additions & 0 deletions
9
view/frontend/templates/product/list/bottom_description.phtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
/* @var Magento\Catalog\Block\Category\View $block */ | ||
/* Copyright © LotsofPixels.io, Inc. All rights reserved. */ | ||
?> | ||
<?php if ($_bottomDescription = $block->getCurrentCategory()->getBottomDescription()): ?> | ||
<div class="category-bottom-description"> | ||
<?= /* @escapeNotVerified */ $this->helper('Magento\Catalog\Helper\Output')->categoryAttribute($block->getCurrentCategory(), $_bottomDescription, 'bottom_description') ?> | ||
</div> | ||
<?php endif; ?> |