Categories
CMS Magento Mastering Development

Custom category attribute is not being saved – issue

I managed to create my custom attribute: $installer = $setup; $installer->startSetup(); $categorySetup = $this->categorySetupFactory->create([‘setup’ => $setup]); $categorySetup->addAttribute( Category::ENTITY, ‘content_category_page’, [ ‘type’ => ‘int’, ‘label’ => ‘Content Page’, ‘input’ => ‘select’, ‘sort_order’ => 100, ‘source’ => ‘Magento\Catalog\Model\Category\Attribute\Source\Page’, ‘global’ => 2, ‘visible’ => true, ‘required’ => true, ‘user_defined’ => false, ‘default’ => null, ‘group’ => ‘General Information’, […]

Categories
CMS Magento Mastering Development

Install Data is not executed in magento 2

I am trying to create a category attribute: This is my file form Vendor/Module/Setup: use Magento\Catalog\Model\Category; use Magento\Catalog\Setup\CategorySetupFactory; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; class InstallData implements InstallDataInterface { private $categorySetupFactory; public function __construct(CategorySetupFactory $categorySetupFactory) { $this->categorySetupFactory = $categorySetupFactory; } public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { $installer = $setup; $installer->startSetup(); $categorySetup = $this->categorySetupFactory->create([‘setup’ => […]

Categories
CMS Magento Mastering Development

Display custom category attribute on category page in Magento 2

I’ve created a module to add a custom category attribute (heading) to a category page. The attribute displays in the admin and I can save the value. I’m wondering what is the best way to display this on a category page? Example/CategoryHeading/etc/module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Example_CategoryHeading" setup_version="0.0.1"> </module> </config> Example/CategoryHeading/Setup/InstallData.php <?php namespace […]

Categories
CMS Development Magento

No able to Retrieve Custom attibute value of a catgeory in magento 2

I have created a custom attribute for my category. Below is my code. In InstallData.php <?php /* file: app/code/Atwix/CategoryAttribute/Setup/InstallData.php */ namespace Vidushi\KeyFeature\Setup; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Eav\Setup\EavSetup; use Magento\Eav\Setup\EavSetupFactory; use Magento\Catalog\Model\Category; use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface; /** * @codeCoverageIgnore */ class InstallData implements InstallDataInterface { /** * @var EavSetupFactory */ private $eavSetupFactory; /** * * […]