Skip to main content
added 6 characters in body; edited tags
Source Link
7ochem
  • 7.6k
  • 14
  • 52
  • 80

I am bit confused about using Resourceresource model and collection Model,model. Sometimes when I see examples for loading products using specific attributes., in some examples, they use collection model and sometimes they use Resourceresource model and.

Also when can I use specific method getget... and setset... along with table row name..? Like getNamegetName, getIdgetId. I tried to use but unable get the values and it shows error.."calling: "calling undefined method in object"

$product = Mage::getModel('catalog/product')
    ->loadByAttribute('name', 'product_name');
      
 echo $product->getName(); 
 echo $product->getSku();

itIt shows undefined"undefined method getSku()...getSku()"

ifIf I use Var_dumpvar_dump($product) .. sku, SKU shows in object, however unable to get the SKU using getSku()...

Thank you all :)

I am bit confused about using Resource model and collection Model, Sometimes when I see examples for loading products using specific attributes. in some examples, they use collection model and sometimes they use Resource model and when can I use specific method get and set along with table row name.. Like getName, getId. I tried to use but unable get the values and it shows error.."calling undefined method in object"

$product = Mage::getModel('catalog/product')->loadByAttribute('name', 'product_name');
      
 echo $product->getName(); 
 echo $product->getSku();

it shows undefined method getSku()...

if I use Var_dump($product) .. sku shows in object however unable to get the SKU using getSku()...

Thank you all :)

I am bit confused about using resource model and collection model. Sometimes when I see examples for loading products using specific attributes, in some examples, they use collection model and sometimes they use resource model.

Also when can I use specific method get... and set... along with table row name? Like getName, getId. I tried to use but unable get the values and it shows error: "calling undefined method in object"

$product = Mage::getModel('catalog/product')
    ->loadByAttribute('name', 'product_name');
      
echo $product->getName(); 
echo $product->getSku();

It shows "undefined method getSku()"

If I use var_dump($product), SKU shows in object, however unable to get the SKU using getSku()...

Tweeted twitter.com/#!/StackMagento/status/343367951266770944
Source Link
MagentoBoy
  • 655
  • 1
  • 10
  • 25

About Collection Model and Resource Model

I am bit confused about using Resource model and collection Model, Sometimes when I see examples for loading products using specific attributes. in some examples, they use collection model and sometimes they use Resource model and when can I use specific method get and set along with table row name.. Like getName, getId. I tried to use but unable get the values and it shows error.."calling undefined method in object"

$product = Mage::getModel('catalog/product')->loadByAttribute('name', 'product_name');
      
 echo $product->getName(); 
 echo $product->getSku();

it shows undefined method getSku()...

if I use Var_dump($product) .. sku shows in object however unable to get the SKU using getSku()...

Thank you all :)