Skip to main content
1 of 2

Fail to override interface module in magento2

i need problem with extension interface in magento2.

Mi extension_attributes.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
    <extension_attributes for="Magento\SalesRule\Api\Data\CouponGenerationSpecInterface">
        <attribute code="specific" type="string" />
    </extension_attributes>
</config>

Mi di.xml

<preference for="Magento\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Form"
            type="Custom\SalesRule\Block\Adminhtml\Promo\Quote\Edit\Tab\Coupons\Form" />
<preference for="Magento\SalesRule\Helper\Coupon"
            type="Custom\SalesRule\Helper\Coupon"/>
<preference for="Magento\SalesRule\Model\Service\CouponManagementService"
            type="Custom\SalesRule\Model\Service\CouponManagementService"/>
<preference for="Magento\SalesRule\Model\Coupon\Massgenerator"
            type="Custom\SalesRule\Model\Coupon\Massgenerator"/>
<preference for="Magento\SalesRule\Model\Data\CouponGenerationSpec"
            type="Custom\SalesRule\Model\Data\CouponGenerationSpec"/>

Mi model/data:

<?php
namespace Custom\SalesRule\Model\Data;

class CouponGenerationSpec extends \Magento\SalesRule\Model\Data\CouponGenerationSpec
{
    const KEY_SPECIFIC = 'specific';

    public function getSpecific()
    {
        return $this->_get(self::KEY_SPECIFIC);
    }


    public function setSpecific($specific)
    {
        return $this->setData(self::KEY_SPECIFIC, $specific);
    }
}

The $specific return null ever. My CouponGenerationSpecExtensionInterface.php and CouponGenerationSpecExtension.php extended setSpecific y getSpecific but i never can enter in $specific.