androider
androider

Reputation: 992

Magento Camel Case Conversion

I have a column name productId. After retrieving collection from magento model, I need to retrieve this productId. I do $product->getProductId(). Its not working. However if change column name to productid and I do $product->getProductid(), it works fine. How should I retrive this column value. P.S. I can't change the column name to productid or product_id

Upvotes: 0

Views: 437

Answers (2)

Imaginaerum
Imaginaerum

Reputation: 779

Your column name must be product_id if you want: $product->getProductId() or $product->getData('product_id'). If you use productId as column name, you can't use magical $product->getProductId()

Upvotes: 0

Erik Dannenberg
Erik Dannenberg

Reputation: 6086

The 'magic' getters are just a wrapper for getData, try $product->getData('productId').

Upvotes: 1

Related Questions