Assume you have a custom block (Startupready/Myrules/Block) for your template. Inside the block call the model and render the data like getPosts()
in the below example, in your case $price_rules->load($priceRuleList);
and return the result.
In the templates call $result = $block->load();
Then process the data.
I have placed some sample example code how to call, by using this approach you can process your code.
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Ashsmith\Blog\Model\ResourceModel\Post\CollectionFactory $postCollectionFactory,
array $data = []
) {
parent::__construct($context, $data);
$this->_postCollectionFactory = $postCollectionFactory;
}
/**
* @return \Ashsmith\Blog\Model\ResourceModel\Post\Collection
*/
public function getPosts()
{
// Check if posts has already been defined
// makes our block nice and re-usable! We could
// pass the 'posts' data to this block, with a collection
// that has been filtered differently!
if (!$this->hasData('posts')) {
$posts = $this->_postCollectionFactory
->create()
->addFilter('is_active', 1)
->addOrder(
PostInterface::CREATION_TIME,
PostCollection::SORT_ORDER_DESC
);
$this->setData('posts', $posts);
}
return $this->getData('posts');
}