Stefan Brendle
Stefan Brendle

Reputation: 1564

Get all field names from magento model

How can I get all field names from an object like "order" without creating or loading this object?

Example:

Model: sales/order

With a loaded order and the getData() method I get an array of various field names like:

shipping_tax_amount
grand_total
base_tax_amount

How can I get these field names without an order? In my case it must be possible to access to this fields even if there is no order at the magento shop.

Upvotes: 6

Views: 5619

Answers (1)

Amit Bera
Amit Bera

Reputation: 7611

  $resource = Mage::getSingleton('core/resource');
   $readConnection = $resource->getConnection('core_read');  
    /**
     * Get the table name
     */
    $tableName = $resource->getTableName('sales/order');

$saleafield=$readConnection->describeTable($tableName);
var_dump($saleafield);

Upvotes: 6

Related Questions