What is the suggested method for tracking COGS for products within Magento? We have recently learned that it will be necessary to track the inbound cost of each item that is sold in the store and it seems that this might be something that would be provided by Magento out of the box, however I'm not seeing this option.

One option I've seen is to perhaps follow the method outlined here: "How do i show Manufacturer’s Suggested Retail Price?," however I'm just not convinced that this is the right vector of attack.


Cost of goods sold (COGS) refer to the inventory costs of those goods a business has sold during a particular period.

So let's get the obvious out of the way: Magento has a cost attribute already set up:

enter image description here

But in reality this isn't going to do us any good at all unless we are using Average Cost as our calculation method (and we assume that the price of these goods will never change, which they will, but in this example they won't ... even though they will).

If that is the case, we define our average cost method:

Average cost. The average cost method relies on average unit cost to calculate cost of units sold and ending inventory.

OK, so something happens where we determine that, on average, a product costs a specific amount to the company. Store that in the cost attribute. Then we calculate COGS:

Per Sales over Lifetime on a Single SKU:

/* Get only sales items with sku of SKU001 that are parents or simples */
$collection = Mage::getResourceModel('sales/order_item')

$COGS = 0.00;
foreach($collection as $_item){
    $COGS += $_item->getProduct()->getCost()
return $COGS;

Well that wasn't too difficult for average cost, although it's not any good for a 'report'. As homework you could create a custom collection with columns that have Zend_Db_Expr to get a columnar view of all SKUs and their associated costs.

Let's look at the other methods:

  • LIFO
  • FIFO
  • Specific Identification


The newest items in inventory are sold off first. This would make for inventory tracking challenges in Magento since Lots and costs are not tracked. Lot number needs to be tracked at the time of purchase and a record of Lots v. Costs would have to be consulted in order to generate the report using the appropriate calculation method.


Oldest items in inventory are used to fulfill current orders. Same challenges or implementation methods realized with inventory management as LIFO.

Specific Identification

Every product is added to the catalog with its own SKU and cost data. Cumbersome. Custom dev required to merchandise a canonical version of the product. Don't do this in Magento - it sounds awful; find an ERP integration that has an inventory and P&L / reporting modules.


Calculating based on Average is fairly simple.

Other calculation methods require work and development. In general, a product belonging to a Lot needs to have its own SKU and cost data saved to the database. Custom reporting required - nothing built-in.

Best of luck.

Source: http://en.wikipedia.org/wiki/Cost_of_goods_sold

|improve this answer|||||
  • 2
    Okay, this is quite helpful and actually a very good answer. The user misexplained what they wanted it appears. The real desired answer is simply for: how do I record our wholesale cost of items? In other words, we need to record the cost of an item before markup is assigned to it. This is wholly for accounting purposes so that a report can be created to show the costs of items vs the costs at which they were sold down the road. – ylluminate Jul 18 '13 at 21:54
  • 2
    Well. Goodness. That's already set up on the cost attribute. Go to Products > Select Product > Prices > Cost. Save the value there. – philwinkle Jul 18 '13 at 22:01
  • 1
    LOL, thanks. Notwithstanding, your initial answer was fantastic and will be something to actually look into as I think it really merits implementation. – ylluminate Jul 19 '13 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.