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');
    }

1 comment:

  1. Casino Tycoon NJ - Mapyro
    Casino Tycoon is a luxury, fun casino 파주 출장샵 and hotel that is located near the Mystic River in Uncasville, CT. It offers more than 1,000 slot machines 상주 출장마사지 and 서귀포 출장샵 over 오산 출장마사지 500 table  Rating: 8.1/10 · 아산 출장마사지 ‎2,939 reviews · ‎Price range: ($)

    ReplyDelete