I'm trying to extend the Magento2 AheadWorks StoreLocator module by adding an additional field - store type. All works fine on the FE side. On the admin side however I've encountered some obstacles when adding/editing locations - the new field is not being saved.
On a high level, the Magento2 StoreLocator Grid save logic is based on the \Aheadworks\StoreLocator\Api\Data\LocationInterface
and the ReflectionClass
to produce the location entity data model and then intersect it with the submitted form data. This means that if I want to add another field I need to add the corresponding setter and getter for the field I want to add. I tried the following:
below is a sample of the AW Module interface definition; it contains setters and getters for all database fields;
namespace Aheadworks\StoreLocator\Api\Data;
use Magento\Framework\Api\ExtensibleDataInterface;
/**
* Location interface.
*/
interface LocationInterface extends ExtensibleDataInterface
{
const LOCATION_ID = 'location_id';
/**
* Get location id
*
* @api
* @return int|null
*/
public function getLocationId();
/**
* Set location id
*
* @api
* @param int $id
* @return $this
*/
public function setLocationId($id);
below is how I'm trying to add the extra field following the implementation in the parent interface;
namespace MyCustomModule\StoreLocator\Api\Data;
interface LocationInterface extends \Aheadworks\StoreLocator\Api\Data\LocationInterface
{
const STORE_TYPE = 'store_type';
/**
* Get Store Type
*
* @api
* @return mixed|null
*/
public function getStoreType();
/**
* Set Store Type
*
* @api
* @param $storeType
* @return $this
*/
public function setStoreType($storeType);
}
The issue is that Magento\Framework\Reflection\MethodsMap::getMethodMapViaReflection
method is not picking up the extending MyCustomModule\StoreLocator\Api\Data\LocationInterface
.
Any thoughts on how I can overcome this. Is there a M2 way to extend interfaces?