Update product category view to include default price_display configured by category
This commit is contained in:
@@ -43,9 +43,48 @@ class Model_Product extends ORM_OSB {
|
||||
|
||||
// Our attributes that are arrays, we'll convert/unconvert them
|
||||
protected $_serialize_column = array(
|
||||
'avail_category',
|
||||
'price_group',
|
||||
);
|
||||
|
||||
/**
|
||||
* Which categories is this product available in
|
||||
*/
|
||||
public function categories() {
|
||||
return $this->avail_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product description, after translating
|
||||
* @todo This needs to be improved to find the right language item.
|
||||
*/
|
||||
public function description_long() {
|
||||
return $this->product_translate->find()->display('description_full');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product description, after translating
|
||||
* @todo This needs to be improved to find the right language item.
|
||||
*/
|
||||
public function description_short() {
|
||||
return $this->product_translate->find()->display('description_short');
|
||||
}
|
||||
|
||||
/**
|
||||
* This will render the product feature summary information
|
||||
*/
|
||||
public function feature_summary() {
|
||||
return (is_null($plugin = $this->plugin())) ? HTML::nbsp('') : $plugin->feature_summary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product name, after translating
|
||||
* @todo This needs to be improved to find the right language item.
|
||||
*/
|
||||
public function name() {
|
||||
return $this->product_translate->find()->display('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the object of the product plugin
|
||||
*/
|
||||
@@ -59,21 +98,6 @@ class Model_Product extends ORM_OSB {
|
||||
return ORM::factory(sprintf('Product_Plugin_%s',$this->prod_plugin_file),$this->prod_plugin_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product name, after translating
|
||||
* @todo This needs to be improved to find the right language item.
|
||||
*/
|
||||
public function name() {
|
||||
return $this->product_translate->find()->display('name');
|
||||
}
|
||||
|
||||
/**
|
||||
* This will render the product feature summary information
|
||||
*/
|
||||
public function feature_summary() {
|
||||
return (is_null($plugin = $this->plugin())) ? HTML::nbsp('') : $plugin->feature_summary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the best price to the uesr based on the users group's memberships
|
||||
* @todo This needs to be tested with more than one price group enabled
|
||||
@@ -190,28 +214,13 @@ class Model_Product extends ORM_OSB {
|
||||
/**
|
||||
* Return the price for the particle group and price option for the period
|
||||
*/
|
||||
public function price($grp,$period,$option) {
|
||||
public function price($grp,$period,$option,$taxed=FALSE) {
|
||||
$x = $this->keyget('price_group',$period);
|
||||
|
||||
return isset($x[$grp][$option]) ? $x[$grp][$option] : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the products for a given category
|
||||
* @todo This shouldnt be here.
|
||||
*/
|
||||
public function list_category($cat,$active=TRUE) {
|
||||
$results = array();
|
||||
|
||||
$cats = $active ? $this->_where_active() : $this;
|
||||
|
||||
foreach ($cats->find_all() as $po) {
|
||||
if ($c = unserialize($po->avail_category) AND in_array($cat,$c))
|
||||
array_push($results,$po);
|
||||
}
|
||||
|
||||
Sort::MAsort($results,'position,price_base');
|
||||
return $results;
|
||||
if (isset($x[$grp][$option]))
|
||||
return $taxed ? Tax::add($x[$grp][$option]) : $x[$grp][$option];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user