Skip to main content
deleted 5 characters in body
Source Link

Try this to get collection,

In your block add the below code

<?php                                                                 
namespace Vendor\Module\Block;                                              
use Magento\Framework\View\Element\Template;                              
class Block_Name extends Template{
public function __construct(
    \Vendor\Module\Model\model_nameFactory $collectionFactory
) {
    $this->collectionFactory = $collectionFactory;
}

public function getCheckoutSessiongetCollection($productId = '')
{
    $collection = $this->collectionFactory->create()->getCollection()->addFieldToSelect('*')->addFieldToFilter('serial_number', array(
        'eq' => '1'
    ));
    //$this->collectionFactory->create()->getCollection()->addFieldToFilter('serial_number', '1');
    $getCollection = array();
    foreach ($collection as $item) {
        $collection$getCollection[] = $item->getSomeText();  //Get some text
    }
    return $getCollection;
}}

Hope it helps :)

Try this to get collection,

In your block add the below code

<?php                                                                 
namespace Vendor\Module\Block;                                              
use Magento\Framework\View\Element\Template;                              
class Block_Name extends Template{
public function __construct(
    \Vendor\Module\Model\model_nameFactory $collectionFactory
) {
    $this->collectionFactory = $collectionFactory;
}

public function getCheckoutSession($productId = '')
{
    $collection = $this->collectionFactory->create()->getCollection()->addFieldToSelect('*')->addFieldToFilter('serial_number', array(
        'eq' => '1'
    ));
    //$this->collectionFactory->create()->getCollection()->addFieldToFilter('serial_number', '1');
    foreach ($collection as $item) {
        $collection = $item->getSomeText();  //Get some text
    }
}}

Hope it helps :)

Try this to get collection,

In your block add the below code

<?php                                                                 
namespace Vendor\Module\Block;                                              
use Magento\Framework\View\Element\Template;                              
class Block_Name extends Template{
public function __construct(
    \Vendor\Module\Model\model_nameFactory $collectionFactory
) {
    $this->collectionFactory = $collectionFactory;
}

public function getCollection($productId = '')
{
    $collection = $this->collectionFactory->create()->getCollection()->addFieldToFilter('serial_number', array(
        'eq' => '1'
    ));
    //$this->collectionFactory->create()->getCollection()->addFieldToFilter('serial_number', '1');
    $getCollection = array();
    foreach ($collection as $item) {
        $getCollection[] = $item->getSomeText();  //Get some text
    }
    return $getCollection;
}}

Hope it helps :)

Source Link

Try this to get collection,

In your block add the below code

<?php                                                                 
namespace Vendor\Module\Block;                                              
use Magento\Framework\View\Element\Template;                              
class Block_Name extends Template{
public function __construct(
    \Vendor\Module\Model\model_nameFactory $collectionFactory
) {
    $this->collectionFactory = $collectionFactory;
}

public function getCheckoutSession($productId = '')
{
    $collection = $this->collectionFactory->create()->getCollection()->addFieldToSelect('*')->addFieldToFilter('serial_number', array(
        'eq' => '1'
    ));
    //$this->collectionFactory->create()->getCollection()->addFieldToFilter('serial_number', '1');
    foreach ($collection as $item) {
        $collection = $item->getSomeText();  //Get some text
    }
}}

Hope it helps :)