I am trying to add a custom attribute to a CMS page in Magento 2.

As it seems there is no way of using EAV, since the Page model does not have entity types.

I tried to add an Extension Attribute, and using a preference for the CMS Page form, like described in this answer and added a field to the CmsPage edit form, but I can't get the plugin for the save functionality in PageRepositoryInterface to work.

The Extension Attribute is added as follows in etc/extension_attributes.xml:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="Magento\Cms\Api\Data\PageInterface">
    <attribute code="slider" type="VanOns\Slider\Api\Data\SliderInterface[]"/>

The plugin for the PageRepositoryInterface in etc/di.xml:

<type name="Magento\Cms\Api\PageRepositoryInterface">
    <plugin name="pageAroundSave" type="VanOns\Slider\Model\Plugin\AroundPageRepositorySave"/>

If I use a logger in my aroundSave function, it won't log anything, suggesting it doesn't pass this function.

Any idea's on how to fix this?



Browse other questions tagged or ask your own question.