Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
Renen Donkers committed Oct 15, 2023
0 parents commit d491849
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 0 deletions.
86 changes: 86 additions & 0 deletions Setup/Patch/Data/bottomdesciptionAttribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
/**
* Copyright &copy; 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 [];
}
}
24 changes: 24 additions & 0 deletions composer.json
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"

}
10 changes: 10 additions & 0 deletions etc/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!--
/**
* Copyright &copy; 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>
5 changes: 5 additions & 0 deletions registration.php
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__);
36 changes: 36 additions & 0 deletions view/adminhtml/ui_component/category_form.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" ?>
<!--
/**
* Copyright &copy; 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>
13 changes: 13 additions & 0 deletions view/frontend/layout/catalog_category_view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0"?>
<!--
/**
* Copyright &copy; 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 view/frontend/templates/product/list/bottom_description.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/* @var Magento\Catalog\Block\Category\View $block */
/* Copyright &copy; 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; ?>

0 comments on commit d491849

Please sign in to comment.