Press "Enter" to skip to content

Tag: shopping

PHP: Magento – current stock value

If you run the Magento ecommerce shopping cart software and you want to find out how much your stock is worth, how many product lines you have stocked and how many individual items you have, you may find the following MySQL query handy.

I’m assuming that you’ve created an attribute with the attribute code “supplier_price” as a decimal, that you’ve kept this field up to date and your stock levels are accurate 😀 If it isn’t called “supplier_price” change the appropriate part in the query.

SELECT
COUNT(sku) AS 'products_stocked',
SUM(qty) AS 'items_in_stock',
SUM(stockvalue) AS 'stock_value'
FROM (

SELECT
catalog_product_entity.sku,
cataloginventory_stock_item.qty,
catalog_product_entity_decimal.value,
(cataloginventory_stock_item.qty * catalog_product_entity_decimal.value) AS stockvalue
FROM
cataloginventory_stock_item,
catalog_product_entity,
eav_attribute,
catalog_product_entity_decimal
WHERE
catalog_product_entity.type_id='simple' AND
cataloginventory_stock_item.product_id=catalog_product_entity.entity_id AND
catalog_product_entity_decimal.entity_id=catalog_product_entity.entity_id AND
eav_attribute.attribute_id=catalog_product_entity_decimal.attribute_id AND
eav_attribute.attribute_code='supplier_price' AND
cataloginventory_stock_item.qty > 0
ORDER BY sku ASC) AS b

Thank You Tesco for the cheap Lexmark printer

I’d just like to say thank you to Tesco’s Beaumont Leys store for supplying me with a Lexmark Wireless All-In-One X4850 printer for just £69.97 – it should retail for £129.99 according to Lexmark (and, according to Tesco, £129.97).

So how do I get it so cheap? Well, I saw a yellow “Discount” shelf edge label promoting the printer for £99.97 so I thought, since I’ve been looking for a cheapish wireless printer for a while, I’ll buy it. Got to the checkout and it was rang up for the normal full price of £129.97. So I wander over to the Electrics customer services – point out that they’ve overcharged me by £30 and they check and agree. They then remind me (although I hadn’t forgotten and would have reminded them if necessary) that Tesco’s pricing promise means that if they make a pricing mistake – you get refunded double the difference. So my £30 over-payment became a £60 credit in my favour.

I’ve just finished setting it up, and the setup was very simple (hardest part was finding where in the house to situate it) and it works well with our SSID hidden WPA2 protected wireless network (much better than the Nokia N95 Series 1 phone which needed the SSID to be visible). Print quality is as good as you would expect from an inkjet on nearly 10 year old cheap 80gsm white laser copier paper (I brought a whole box full from Office World when I was at college and I’ve still got over a ream left) and scanning seems ok. Only disappointment is that the PictBridge software on the printer won’t talk directly to my Japanese-brought Ricoh Capilo RX camera over USB: I’ve got to eject the SD card and insert it into the printer: but at least it gives the option to manipulate/change the photo a bit (borders/frame, red eye reduction, cropping, rotation etc).

Not too bad for £69.97 IMHO!