Pergunta

I'm trying to retrieve a row from a custom table named 'lmap_shipping_tablerate' using a specific value for a column postcode.

An empty array is returned when following line is used in my ResourceModel php file.

use MyVendor\MyModule\Model\Carrier\ResourceModel\Shipping\CollectionFactory;    
$postcode_rate_row = $this->collectionFactory->create()->getItemsByColumnValue('postcode', $value);
$this->logger->debug('Rates received: '.var_dump($postcode_rate_row));

Below is the directory structure

enter image description here enter image description here

Am I using the collection factory in correct manner.

I have also created a helper file to get the desired row and used the same above code to return the array back to the calling method in ResourceModel php file but again empty array is received.

Foi útil?

Solução

Kindly check other functions

use MyVendor\MyModule\Model\Carrier\ResourceModel\Shipping\CollectionFactory;    
$postcode_rate_row = $this->collectionFactory->create();

print_r(get_class_methods($postcode_rate_row));?>

It return list of methods, choose the correct one.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top