コード例 #1
0
 /**
  * Saves the current products attributes as a template
  * @param $get $_GET
  * @author Sam West aka Nimmit - osc@kangaroopartners.com
  * @return array selected template
  */
 function saveTemplate($get)
 {
     $this->getAndPrepare('template_name', $get, $templateName);
     $this->getAndPrepare('new_template_id', $get, $newTemplateId);
     $allProdOptionsAndValues = $this->getAllProductOptionsAndValues();
     if (strpos($templateName, ':')) {
         $templateNameBits = explode(':', $templateName);
         $templateName = $templateNameBits[1];
     }
     if (0 !== count($allProdOptionsAndValues)) {
         if (0 != $newTemplateId) {
             amDB::query("delete from " . AM_TABLE_ATTRIBUTES_TO_TEMPLATES . " where template_id='{$newTemplateId}'");
         } else {
             $data = array('template_name' => $templateName);
             amDB::perform(AM_TABLE_TEMPLATES, $data);
             $newTemplateId = amDB::insertId();
         }
         //echo '<br><br>Array ALLPRODOPTSAVALS:: <br><br>';
         //print_r($allProdOptionsAndValues);
         foreach ($allProdOptionsAndValues as $optionId => $values) {
             if (is_array($values['values'])) {
                 foreach ($values['values'] as $optionValuesId => $allOptionValues) {
                     if (!AM_USE_SORT_ORDER) {
                         $data = array('template_id' => $newTemplateId, 'options_id' => $optionId, 'option_values_id' => $optionValuesId, 'price_prefix' => $values['values'][$optionValuesId]['prefix'], 'options_values_price' => $values['values'][$optionValuesId]['price']);
                     } else {
                         $data = array('template_id' => $newTemplateId, 'options_id' => $optionId, 'option_values_id' => $optionValuesId, 'price_prefix' => $values['values'][$optionValuesId]['prefix'], 'options_values_price' => $values['values'][$optionValuesId]['price'], 'products_options_sort_order' => $values['values'][$optionValuesId]['sortOrder']);
                     }
                     if (AM_USE_MPW) {
                         $data['weight_prefix'] = $values['values'][$optionValuesId]['weight_prefix'];
                         $data['options_values_weight'] = $values['values'][$optionValuesId]['weight'];
                     }
                     //echo '<br><br>Array DATA:: <br><br>';
                     //print_r($data);
                     amDB::perform(AM_TABLE_ATTRIBUTES_TO_TEMPLATES, $data);
                 }
             }
         }
     }
     return array('selectedTemplate' => $newTemplateId);
 }
コード例 #2
0
 /**
  * Saves the current products attributes as a template
  * @param $get $_GET
  * @author Sam West aka Nimmit - osc@kangaroopartners.com
  * @return array selected template
  */
 function saveTemplate($get)
 {
     $this->getAndPrepare('template_name', $get, $templateName);
     $this->getAndPrepare('new_template_id', $get, $newTemplateId);
     $allOptionsAndValues = $this->getAllProductOptionsAndValues();
     if (strpos($templateName, ':')) {
         $templateNameBits = explode(':', $templateName);
         $templateName = $templateNameBits[1];
     }
     if (0 !== count($allOptionsAndValues)) {
         if (0 != $newTemplateId) {
             amDB::query("delete from " . AM_TABLE_ATTRIBUTES_TO_TEMPLATES . " where template_id='{$newTemplateId}'");
         } else {
             $data = array('template_name' => $templateName);
             amDB::perform(AM_TABLE_TEMPLATES, $data);
             $newTemplateId = amDB::insertId();
         }
         foreach ($allOptionsAndValues as $optionId => $values) {
             if (is_array($values['values'])) {
                 foreach ($values['values'] as $optionValuesId => $dontneed) {
                     $data = array('template_id' => $newTemplateId, 'options_id' => $optionId, 'option_values_id' => $optionValuesId);
                     amDB::perform(AM_TABLE_ATTRIBUTES_TO_TEMPLATES, $data);
                 }
             }
         }
     }
     return array('selectedTemplate' => $newTemplateId);
 }