/** * Function to quickly check whether a product has attributes or not * * @param int $pid The id of the product to check * @return boolean True when the product has attributes, false when not */ function product_has_attributes($pid, $checkSimpleAttributes=false ) { if( is_array($pid) || empty($pid)) { return false; } $pid = intval( $pid ); $db = new ps_DB; if( empty($GLOBALS['product_info'][$pid]["product_has_attributes"] )) { $db->query( "SELECT `product_id` FROM `#__{vm}_product_attribute_sku` WHERE `product_id`=$pid"); if ($db->next_record()) { $GLOBALS['product_info'][$pid]["product_has_attributes"] = True; } elseif( $checkSimpleAttributes ) { $db->query( "SELECT `attribute`,`custom_attribute` FROM `#__{vm}_product` WHERE `product_id`=$pid"); $db->next_record(); if( $db->f('attribute') || $db->f('custom_attribute')) { $GLOBALS['product_info'][$pid]["product_has_attributes"] = True; } else { $GLOBALS['product_info'][$pid]["product_has_attributes"] = False; } } else { $GLOBALS['product_info'][$pid]["product_has_attributes"] = False; } } return $GLOBALS['product_info'][$pid]["product_has_attributes"]; }