Mar 28, 2017

Magento 2 Getter and Setter Generator

Magento 2 is going away from magic methods and many of Magento 2 classes have getters and setters in their classes.

However, it's time consuming to create these all all your properties on your CRUD Model, so this is why I've created a small tool that generates the getters and setters.



Generate getters and setters

Add your attribute in snake case, comma-seperated in the above input field.




    /**
    * @param $attributeId
    * @return $this
    */
    public function setAttributeId($attributeId)
    {
        return $this->setData('attribute_id', $attributeId);
    }

    /**
    * @param $colorKey
    * @return $this
    */
    public function setColorKey($colorKey)
    {
        return $this->setData('color_key', $colorKey);
    }

    /**
    * @return mixed
    */
    public function getAttributeId()
    {
        return $this->getData('attribute_id');
    }

    /**
    * @return mixed
    */
    public function getColorKey()
    {
        return $this->getData('color_key');
    }

No comments:

Post a Comment