Blakewilliams Posted January 11, 2010 Share Posted January 11, 2010 Hey!Just wondering if anybody could shed some light with how I get the prices by the attribute buttons that I have created....I'm getting to know how the structure of the shop operates now - I know that this section of the products class:: public function getAttributesGroups($id_lang) { return Db::getInstance()->ExecuteS(' SELECT ag.`id_attribute_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name, a.`color` AS attribute_color, pa.`id_product_attribute`, pa.`quantity`, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference` FROM `'._DB_PREFIX_.'product_attribute` pa LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute` a ON a.`id_attribute` = pac.`id_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag ON ag.`id_attribute_group` = a.`id_attribute_group` LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al ON a.`id_attribute` = al.`id_attribute` LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl ON ag.`id_attribute_group` = agl.`id_attribute_group` WHERE pa.`id_product` = '.intval($this->id).' AND al.`id_lang` = '.intval($id_lang).' AND agl.`id_lang` = '.intval($id_lang).' ORDER BY pa.`id_product_attribute`'); } Retrieves the data, then the logic happens here, and various array modifications (products.php) $attributesGroups = $product->getAttributesGroups(intval($cookie->id_lang)); if (Db::getInstance()->numRows()) { $combinationImages = $product->getCombinationImages(intval($cookie->id_lang)); foreach ($attributesGroups AS $k => $row) { /* Color management */ if (isset($row['attribute_color']) AND $row['attribute_color'] AND $row['id_attribute_group'] == $product->id_color_default) { $colors[$row['id_attribute']]['value'] = $row['attribute_color']; $colors[$row['id_attribute']]['name'] = $row['attribute_name']; } $groups[$row['id_attribute_group']]['attributes'][$row['id_attribute']] = $row['attribute_name']; $groups[$row['id_attribute_group']]['name'] = $row['public_group_name']; if ($row['default_on']) $groups[$row['id_attribute_group']]['default'] = intval($row['id_attribute']); if (!isset($groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']])) $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] = 0; $groups[$row['id_attribute_group']]['attributes_quantity'][$row['id_attribute']] += intval($row['quantity']); $combinations[$row['id_product_attribute']]['attributes_values'][$row['id_attribute_group']] = $row['attribute_name']; $combinations[$row['id_product_attribute']]['attributes'][] = intval($row['id_attribute']); $combinations[$row['id_product_attribute']]['price'] = floatval($row['price']); $combinations[$row['id_product_attribute']]['ecotax'] = floatval($row['ecotax']); $combinations[$row['id_product_attribute']]['weight'] = floatval($row['weight']); $combinations[$row['id_product_attribute']]['quantity'] = intval($row['quantity']); $combinations[$row['id_product_attribute']]['reference'] = $row['reference']; $combinations[$row['id_product_attribute']]['id_image'] = isset($combinationImages[$row['id_product_attribute']][0]['id_image']) ? $combinationImages[$row['id_product_attribute']][0]['id_image'] : -1; } But I need the variable for the price to be included in the for each loop that Tomer helped me with (below) {if $groups|@count == 1} [removed] $("#attributes").css('display','none'); $("#add_to_cart_hide").css('display','none'); [removed] {foreach from=$groups key=id_attribute_group item=group} {assign var='groupName' value='group_'|cat:$id_attribute_group} {foreach from=$group.attributes key=id_attribute item=group_attribute} <input> {/foreach} {/foreach} Really appreciate some help here!Blake Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now