Posts Tagged ‘magento’

PHP: Magento – current stock value

August 13th, 2011

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 :-D 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

Book Review: php|architect’s Guide to E-commerce Programming with Magento

November 30th, 2008

I’ve decided to switch the back end of my side-line e-commerce dance wear and leisure wear clothing site from ClickCartPro to Magento. Why? Well, Magento is cheaper (moot point as I’ve already brought the licence for ClickCartPro), Open Source (so’s ClickCartPro), is more flexible (so it seems), has more options and it’s another shopping cart system for me to learn and have experience with (plus it does seem to be growing in popularity quite a bit).

However, the switch has come with a price: it’s quite a complex bit of kit! So, since Waterstones had an offer on and I needed to buy some other books I purchased php|architect’s Guide To E-Commerce Programming with Magento from them (Waterstones’ price is £19.99 and Amazon’s is £18.99: both with free shipping. It’s also available as a PDF for $29.99 from the publisher’s site). Why did I buy this book? Well, it was the only Magento book Waterstones (or Amazon) had!
» Read more: Book Review: php|architect’s Guide to E-commerce Programming with Magento

gamy-dance