Firstly, displaying the price of a grouped product is trivial:
$product = Mage::getModel('catalog/product')->load($product_id);
echo $product->getPrice();
Secondly, where it is stored and how it is calculated is not so much complex as it is undesirable. Accessing the database directly for pricing will not respect the custom options related to pricing that are set on the backend:
- Display price before tax
- Display "as low as" for configurables
- Display in alternate currencies based on store view language config
So I suggest you not do this in your module. However for purely academic reasons, all pricing can be found for a product in one of two ways:
If you're using flat catalog
SELECT sku, price from catalog_product_flat_1 where sku='[your_grouped_sku]';
Note: the last _1
of the table name is generally the internal id of the store view code.
If you're not using flat catalog
This gets tricky because your eav attribute id for base pricing may be different than mine - Mine are entity_type_id = 4, attribute_id=64. Make sure to look yours up via attribute_code
in eav_attribute
table:
SELECT sku, price.value AS price
FROM catalog_product_entity
LEFT JOIN catalog_product_entity_decimal price ON (price.`entity_type_id`=4) AND (price.`attribute_id`=64)
WHERE sku='[your sku]'
How you should be doing this
Use a custom collection that extends an existing collection - joining on your custom table. Because you haven't provided any direction here this is intended to be pseudo-code that will point you in the right direction. This is in no way complete and is not a drop-in fix to provide your own collection.
<?php
class YourCompany_Module_Model_Feature_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
protected function _prepareCollection()
{
$collection = Mage::getModel('catalog/product')->getCollection();
$your_table = $this->getTable('yourmodule/model');
$collection->getSelect()
->joinLeft(array('a'=>$your_table),'a.entity_id=main_table.entity_id');
return $collection;
}
}
For more on creating and working with custom collections see these articles:
http://alanstorm.com/magento_models_orm
http://alanstorm.com/magento_collections
For your problem
You can look in this file
vendor/magento/module-catalog/Model/Product/Type/Price.php
Go to above file and start debugging as your issue related to tier price
you can look below methods for this issue
getBasePrice()
_applyTierPrice()
calculatePrice()
I think you need to modify all three methods.
Best Answer
This is actually by design.
Magento will show the minimum price, because the retail price should always be higher then the group prices (otherwise, why wouldn't the customer just not login then attempt to checkout).
This is evident in the following function:
Source: app/code/core/Mage/Catalog/Model/Product/Type/Price.php
So running through you scenario above, using EE 1.13, I logged into a customer account. The regular price of the product was $150. The retailer group price I set as $250, and the wholesale group price I set as $125. The wholesale displayed as $125, however the retailer group price was $150. Again, this is as design, it's not a bug but a feature.
You can also try the logic by trying to add a "special price" that is greater then the regular price. The special price won't show.
Solutions for your needs.
If you do end up creating your own extension, always remember to never edit core code.