Read the product options from options.csv

Read the product options from options.csv

function getProductOptions()
{
    $options_arr = array();
    $images = 'csv/options.csv';
    $handle = fopen($images, "r");
    $headers = false;
    if (empty($handle) === false) {
        while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
            if (!$headers) {
                $headers[] = $data;
            } else {
                $options_arr[$data[0]][$data[4]]['option'] = $data[2];
                $options_arr[$data[0]][$data[4]]['type'] = $data[3];
                $options_arr[$data[0]][$data[4]]['required'] = (int)$data[5];
                $options_arr[$data[0]][$data[4]]['sort_order'] = $data[14];
                $options_arr[$data[0]][$data[4]]['value'] = strtolower($data[4]);
                $options_arr[$data[0]][$data[4]]['price'] = $data[8];
                $options_arr[$data[0]][$data[4]]['image'] = trim($data[15]);
                $options_arr[$data[0]][$data[4]]['qty'] = $data[6];
              
            }
        }
        fclose($handle);
    }
    //print_r($options_arr);
    //die();
    return $options_arr;
}

Share this Tutorial