Magento 2 model and collection

Model/Rewards.php

<?php
namespace MagePal\TestDiscount\Model;
use Magento\Framework\Model\AbstractModel;

class Rewards extends AbstractModel
{
protected function _construct()
{
$this->_init(‘MagePal\TestDiscount\Model\Resource\Rewards’);
}

}

Model/resource/Rewards.php

<?php
namespace MagePal\TestDiscount\Model\Resource;
use \Magento\Framework\Model\ResourceModel\Db\AbstractDb;

class Rewards extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
protected function _construct()
{
$this->_init(‘mjweb_customer_rewards’,’id’);
}
}

 

Model/Rewards/Collection.php

<?php
namespace MagePal\TestDiscount\Model\Resource\Rewards;
use \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;;

class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
protected function _construct()
{
$this->_init(‘MagePal\TestDiscount\Model\Rewards’,’MagePal\TestDiscount\Model\Resource\Rewards’);
}

protected function getPointbyCustomerId($customerId)
{

}
}

 

 

 

 

Leave a Comment