Created
May 30, 2016 16:01
-
-
Save halfhope/e808d59de57459a005c4d5b643c4ce58 to your computer and use it in GitHub Desktop.
Faster function getProductOptions for OpenCart module CSV Product Export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function getProductOptions($product_id) { | |
$product_option_query = $this->db->query("SELECT po.product_option_id, po.option_id, od.name as option_name, ovd.name as product_option_value_name, o.type, po.required | |
FROM " . DB_PREFIX . "product_option_value pov | |
LEFT JOIN " . DB_PREFIX . "option_value ov ON (pov.option_value_id = ov.option_value_id) | |
LEFT JOIN " . DB_PREFIX . "option_value_description ovd ON (ov.option_value_id = ovd.option_value_id) | |
LEFT JOIN " . DB_PREFIX . "product_option po ON (pov.product_option_id = po.product_option_id) | |
LEFT JOIN `" . DB_PREFIX . "option` o ON (po.option_id = o.option_id) | |
LEFT JOIN " . DB_PREFIX . "option_description od ON (o.option_id = od.option_id) | |
WHERE pov.product_id = " . (int)$product_id); | |
if (empty($product_option_query->row)) { | |
return false; | |
} | |
$product_option_value_data = array(); | |
$product_option_data = array(); | |
foreach ($product_option_query->rows as $product_option) { | |
$product_option_value_data[$product_option['product_option_id']][]['name'] = $product_option['product_option_value_name']; | |
$product_option_data[$product_option['product_option_id']] = array( | |
'product_option_id' => $product_option['product_option_id'], | |
'option_id' => $product_option['option_id'], | |
'name' => $product_option['option_name'], | |
'type' => $product_option['type'], | |
'required' => $product_option['required'] | |
); | |
$product_option_data[$product_option['product_option_id']]['product_option_value'] =& $product_option_value_data[$product_option['product_option_id']]; | |
} | |
return $product_option_data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment