Exemple #1
0
 protected function prepareGeneralData(array &$data)
 {
     $prepared = parent::prepareData($data);
     $prepared['marketplace_id'] = (int) $data['marketplace_id'];
     $keys = array('country_mode', 'country_custom_value', 'country_custom_attribute', 'postal_code_mode', 'postal_code_custom_attribute', 'postal_code_custom_value', 'address_mode', 'address_custom_attribute', 'address_custom_value', 'dispatch_time', 'global_shipping_program', 'local_shipping_rate_table_mode', 'international_shipping_rate_table_mode', 'local_shipping_mode', 'local_shipping_discount_mode', 'international_shipping_mode', 'international_shipping_discount_mode', 'cross_border_trade');
     foreach ($keys as $key) {
         $prepared[$key] = isset($data[$key]) ? $data[$key] : '';
     }
     if (isset($data['local_shipping_discount_profile_id'])) {
         $prepared['local_shipping_discount_profile_id'] = json_encode(array_diff($data['local_shipping_discount_profile_id'], array('')));
     } else {
         $prepared['local_shipping_discount_profile_id'] = json_encode(array());
     }
     if (isset($data['international_shipping_discount_profile_id'])) {
         $prepared['international_shipping_discount_profile_id'] = json_encode(array_diff($data['international_shipping_discount_profile_id'], array('')));
     } else {
         $prepared['international_shipping_discount_profile_id'] = json_encode(array());
     }
     if (isset($data['excluded_locations'])) {
         $prepared['excluded_locations'] = $data['excluded_locations'];
     }
     if (isset($data['click_and_collect_mode'])) {
         $prepared['click_and_collect_mode'] = (int) $data['click_and_collect_mode'];
     }
     $key = 'cash_on_delivery_cost';
     $prepared[$key] = isset($data[$key]) && $data[$key] != '' ? $data[$key] : NULL;
     $modes = array('local_shipping_rate_table_mode', 'international_shipping_rate_table_mode', 'local_shipping_mode', 'local_shipping_discount_mode', 'international_shipping_mode', 'international_shipping_discount_mode', 'cross_border_trade');
     foreach ($modes as $mode) {
         $prepared[$mode] = (int) $prepared[$mode];
     }
     return $prepared;
 }
Exemple #2
0
 protected function prepareData(array &$data)
 {
     $prepared = parent::prepareData($data);
     // ---------------------------------------
     $prepared['marketplace_id'] = (int) $data['marketplace_id'];
     // ---------------------------------------
     // ---------------------------------------
     if (isset($data['pay_pal_mode'])) {
         $prepared['pay_pal_mode'] = (int) (bool) $data['pay_pal_mode'];
     } else {
         $prepared['pay_pal_mode'] = 0;
     }
     if (isset($data['pay_pal_email_address'])) {
         $prepared['pay_pal_email_address'] = $data['pay_pal_email_address'];
     }
     $prepared['pay_pal_immediate_payment'] = 0;
     if (isset($data['pay_pal_immediate_payment'])) {
         $prepared['pay_pal_immediate_payment'] = (int) (bool) $data['pay_pal_immediate_payment'];
     }
     if (isset($data['services']) && is_array($data['services'])) {
         $prepared['services'] = $data['services'];
     }
     // ---------------------------------------
     return $prepared;
 }
Exemple #3
0
 protected function prepareData(array &$data)
 {
     $prepared = parent::prepareData($data);
     $prepared['marketplace_id'] = (int) $data['marketplace_id'];
     if (isset($data['accepted'])) {
         $prepared['accepted'] = $data['accepted'];
     }
     if (isset($data['option'])) {
         $prepared['option'] = $data['option'];
     }
     if (isset($data['within'])) {
         $prepared['within'] = $data['within'];
     }
     if (isset($data['holiday_mode'])) {
         $prepared['holiday_mode'] = $data['holiday_mode'];
     }
     if (isset($data['shipping_cost'])) {
         $prepared['shipping_cost'] = $data['shipping_cost'];
     }
     if (isset($data['restocking_fee'])) {
         $prepared['restocking_fee'] = $data['restocking_fee'];
     }
     if (isset($data['description'])) {
         $prepared['description'] = $data['description'];
     }
     if ($prepared['accepted'] != 'ReturnsAccepted') {
         $prepared['holiday_mode'] = 0;
     }
     return $prepared;
 }
Exemple #4
0
 protected function prepareData(array &$data)
 {
     $prepared = parent::prepareData($data);
     $defaultData = $this->activeRecordFactory->getObject('Ebay\\Template\\Synchronization')->getDefaultSettings();
     $defaultData['schedule_interval_settings'] = json_decode($defaultData['schedule_interval_settings'], true);
     $defaultData['schedule_week_settings'] = json_decode($defaultData['schedule_week_settings'], true);
     $data = $this->getHelper('Data')->arrayReplaceRecursive($defaultData, $data);
     $prepared = array_merge($prepared, $this->prepareListData($data), $this->prepareReviseData($data), $this->prepareRelistData($data), $this->prepareStopData($data), $this->prepareScheduleData($data));
     return $prepared;
 }
Exemple #5
0
 protected function prepareData(array &$data)
 {
     $prepared = parent::prepareData($data);
     $defaultData = $this->activeRecordFactory->getObject('Ebay\\Template\\SellingFormat')->getDefaultSettings();
     $data = array_merge($defaultData, $data);
     if (isset($data['listing_type'])) {
         $prepared['listing_type'] = (int) $data['listing_type'];
     }
     if (isset($data['listing_is_private'])) {
         $prepared['listing_is_private'] = (int) (bool) $data['listing_is_private'];
     }
     if (isset($data['listing_type_attribute'])) {
         $prepared['listing_type_attribute'] = $data['listing_type_attribute'];
     }
     if (isset($data['duration_mode'])) {
         $prepared['duration_mode'] = (int) $data['duration_mode'];
     }
     if (isset($data['duration_attribute'])) {
         $prepared['duration_attribute'] = $data['duration_attribute'];
     }
     if (isset($data['out_of_stock_control'])) {
         $prepared['out_of_stock_control'] = (int) $data['out_of_stock_control'];
     }
     if (isset($data['qty_mode'])) {
         $prepared['qty_mode'] = (int) $data['qty_mode'];
     }
     if (isset($data['qty_custom_value'])) {
         $prepared['qty_custom_value'] = (int) $data['qty_custom_value'];
     }
     if (isset($data['qty_custom_attribute'])) {
         $prepared['qty_custom_attribute'] = $data['qty_custom_attribute'];
     }
     if (isset($data['qty_percentage'])) {
         $prepared['qty_percentage'] = (int) $data['qty_percentage'];
     }
     if (isset($data['qty_modification_mode'])) {
         $prepared['qty_modification_mode'] = (int) $data['qty_modification_mode'];
     }
     if (isset($data['qty_min_posted_value'])) {
         $prepared['qty_min_posted_value'] = (int) $data['qty_min_posted_value'];
     }
     if (isset($data['qty_max_posted_value'])) {
         $prepared['qty_max_posted_value'] = (int) $data['qty_max_posted_value'];
     }
     if (isset($data['vat_percent'])) {
         $prepared['vat_percent'] = (double) $data['vat_percent'];
     }
     if (isset($data['tax_table_mode'])) {
         $prepared['tax_table_mode'] = (int) $data['tax_table_mode'];
     }
     if (isset($data['tax_category_mode'])) {
         $prepared['tax_category_mode'] = (int) $data['tax_category_mode'];
     }
     if (isset($data['tax_category_value'])) {
         $prepared['tax_category_value'] = $data['tax_category_value'];
     }
     if (isset($data['tax_category_attribute'])) {
         $prepared['tax_category_attribute'] = $data['tax_category_attribute'];
     }
     if (isset($data['price_increase_vat_percent'])) {
         $prepared['price_increase_vat_percent'] = (int) $data['price_increase_vat_percent'];
     }
     if (isset($data['price_variation_mode'])) {
         $prepared['price_variation_mode'] = (int) $data['price_variation_mode'];
     }
     // ---------------------------------------
     if (isset($data['fixed_price_mode'])) {
         $prepared['fixed_price_mode'] = (int) $data['fixed_price_mode'];
     }
     if (isset($data['fixed_price_coefficient'], $data['fixed_price_coefficient_mode'])) {
         $prepared['fixed_price_coefficient'] = $this->getFormattedPriceCoefficient($data['fixed_price_coefficient'], $data['fixed_price_coefficient_mode']);
     }
     if (isset($data['fixed_price_custom_attribute'])) {
         $prepared['fixed_price_custom_attribute'] = $data['fixed_price_custom_attribute'];
     }
     // ---------------------------------------
     if (isset($data['start_price_mode'])) {
         $prepared['start_price_mode'] = (int) $data['start_price_mode'];
     }
     if (isset($data['start_price_coefficient'], $data['start_price_coefficient_mode'])) {
         $prepared['start_price_coefficient'] = $this->getFormattedPriceCoefficient($data['start_price_coefficient'], $data['start_price_coefficient_mode']);
     }
     if (isset($data['start_price_custom_attribute'])) {
         $prepared['start_price_custom_attribute'] = $data['start_price_custom_attribute'];
     }
     // ---------------------------------------
     if (isset($data['reserve_price_mode'])) {
         $prepared['reserve_price_mode'] = (int) $data['reserve_price_mode'];
     }
     if (isset($data['reserve_price_coefficient'], $data['reserve_price_coefficient_mode'])) {
         $prepared['reserve_price_coefficient'] = $this->getFormattedPriceCoefficient($data['reserve_price_coefficient'], $data['reserve_price_coefficient_mode']);
     }
     if (isset($data['reserve_price_custom_attribute'])) {
         $prepared['reserve_price_custom_attribute'] = $data['reserve_price_custom_attribute'];
     }
     // ---------------------------------------
     if (isset($data['buyitnow_price_mode'])) {
         $prepared['buyitnow_price_mode'] = (int) $data['buyitnow_price_mode'];
     }
     if (isset($data['buyitnow_price_coefficient'], $data['buyitnow_price_coefficient_mode'])) {
         $prepared['buyitnow_price_coefficient'] = $this->getFormattedPriceCoefficient($data['buyitnow_price_coefficient'], $data['buyitnow_price_coefficient_mode']);
     }
     if (isset($data['buyitnow_price_custom_attribute'])) {
         $prepared['buyitnow_price_custom_attribute'] = $data['buyitnow_price_custom_attribute'];
     }
     // ---------------------------------------
     if (isset($data['price_discount_stp_mode'])) {
         $prepared['price_discount_stp_mode'] = (int) $data['price_discount_stp_mode'];
     }
     if (isset($data['price_discount_stp_attribute'])) {
         $prepared['price_discount_stp_attribute'] = $data['price_discount_stp_attribute'];
     }
     if (isset($data['price_discount_stp_type'])) {
         $prepared['price_discount_stp_type'] = (int) $data['price_discount_stp_type'];
     }
     // ---------------------------------------
     if (isset($data['price_discount_map_mode'])) {
         $prepared['price_discount_map_mode'] = (int) $data['price_discount_map_mode'];
     }
     if (isset($data['price_discount_map_attribute'])) {
         $prepared['price_discount_map_attribute'] = $data['price_discount_map_attribute'];
     }
     if (isset($data['price_discount_map_exposure_type'])) {
         $prepared['price_discount_map_exposure_type'] = (int) $data['price_discount_map_exposure_type'];
     }
     if (isset($data['restricted_to_business'])) {
         $prepared['restricted_to_business'] = (int) $data['restricted_to_business'];
     }
     // ---------------------------------------
     if (isset($data['best_offer_mode'])) {
         $prepared['best_offer_mode'] = (int) $data['best_offer_mode'];
     }
     if (isset($data['best_offer_accept_mode'])) {
         $prepared['best_offer_accept_mode'] = (int) $data['best_offer_accept_mode'];
     }
     if (isset($data['best_offer_accept_value'])) {
         $prepared['best_offer_accept_value'] = $data['best_offer_accept_value'];
     }
     if (isset($data['best_offer_accept_attribute'])) {
         $prepared['best_offer_accept_attribute'] = $data['best_offer_accept_attribute'];
     }
     if (isset($data['best_offer_reject_mode'])) {
         $prepared['best_offer_reject_mode'] = (int) $data['best_offer_reject_mode'];
     }
     if (isset($data['best_offer_reject_value'])) {
         $prepared['best_offer_reject_value'] = $data['best_offer_reject_value'];
     }
     if (isset($data['best_offer_reject_attribute'])) {
         $prepared['best_offer_reject_attribute'] = $data['best_offer_reject_attribute'];
     }
     if (isset($data['charity_id'], $data['charity_name'], $data['charity_percentage']) && $prepared['is_custom_template'] == 1) {
         $src = array('id' => $data['charity_id'], 'name' => $data['charity_name'], 'percentage' => (int) $data['charity_percentage']);
         $prepared['charity'] = json_encode($src);
     }
     if (isset($data['ignore_variations'])) {
         $prepared['ignore_variations'] = (int) $data['ignore_variations'];
     }
     return $prepared;
 }
Exemple #6
0
 protected function prepareData(array &$data)
 {
     $prepared = parent::prepareData($data);
     $defaultData = $this->activeRecordFactory->getObject('Ebay\\Template\\Description')->getDefaultSettings();
     $defaultData['enhancement'] = explode(',', $defaultData['enhancement']);
     $defaultData['product_details'] = json_decode($defaultData['product_details'], true);
     //        $defaultData['watermark_settings'] = json_decode($defaultData['watermark_settings'], true);
     $data = $this->getHelper('Data')->arrayReplaceRecursive($defaultData, $data);
     if (isset($data['title_mode'])) {
         $prepared['title_mode'] = (int) $data['title_mode'];
     }
     if (isset($data['title_template'])) {
         $prepared['title_template'] = $data['title_template'];
     }
     if (isset($data['subtitle_mode'])) {
         $prepared['subtitle_mode'] = (int) $data['subtitle_mode'];
     }
     if (isset($data['subtitle_template'])) {
         $prepared['subtitle_template'] = $data['subtitle_template'];
     }
     if (isset($data['description_mode'])) {
         $prepared['description_mode'] = (int) $data['description_mode'];
     }
     if (isset($data['description_template'])) {
         $prepared['description_template'] = $data['description_template'];
     }
     if (isset($data['condition_mode'])) {
         $prepared['condition_mode'] = (int) $data['condition_mode'];
     }
     if (isset($data['condition_value'])) {
         $prepared['condition_value'] = (int) $data['condition_value'];
     }
     if (isset($data['condition_attribute'])) {
         $prepared['condition_attribute'] = $data['condition_attribute'];
     }
     if (isset($data['condition_note_mode'])) {
         $prepared['condition_note_mode'] = (int) $data['condition_note_mode'];
     }
     if (isset($data['condition_note_template'])) {
         $prepared['condition_note_template'] = $data['condition_note_template'];
     }
     if (isset($data['product_details'])) {
         $prepared['product_details'] = $data['product_details'];
         if (is_array($prepared['product_details'])) {
             $prepared['product_details'] = json_encode($prepared['product_details']);
         }
     }
     if (isset($data['editor_type'])) {
         $prepared['editor_type'] = (int) $data['editor_type'];
     }
     if (isset($data['cut_long_titles'])) {
         $prepared['cut_long_titles'] = (int) $data['cut_long_titles'];
     }
     if (isset($data['hit_counter'])) {
         $prepared['hit_counter'] = $data['hit_counter'];
     }
     if (isset($data['enhancement'])) {
         $prepared['enhancement'] = $data['enhancement'];
         if (is_array($prepared['enhancement'])) {
             $prepared['enhancement'] = implode(',', $data['enhancement']);
         }
     }
     if (isset($data['gallery_type'])) {
         $prepared['gallery_type'] = (int) $data['gallery_type'];
     }
     if (isset($data['image_main_mode'])) {
         $prepared['image_main_mode'] = (int) $data['image_main_mode'];
     }
     if (isset($data['image_main_attribute'])) {
         $prepared['image_main_attribute'] = $data['image_main_attribute'];
     }
     if (isset($data['gallery_images_mode'])) {
         $prepared['gallery_images_mode'] = (int) $data['gallery_images_mode'];
     }
     if (isset($data['gallery_images_limit'])) {
         $prepared['gallery_images_limit'] = (int) $data['gallery_images_limit'];
     }
     if (isset($data['gallery_images_attribute'])) {
         $prepared['gallery_images_attribute'] = $data['gallery_images_attribute'];
     }
     if (isset($data['variation_images_mode'])) {
         $prepared['variation_images_mode'] = (int) $data['variation_images_mode'];
     }
     if (isset($data['variation_images_limit'])) {
         $prepared['variation_images_limit'] = (int) $data['variation_images_limit'];
     }
     if (isset($data['variation_images_attribute'])) {
         $prepared['variation_images_attribute'] = $data['variation_images_attribute'];
     }
     if (isset($data['reserve_price_custom_attribute'])) {
         $prepared['reserve_price_custom_attribute'] = $data['reserve_price_custom_attribute'];
     }
     if (isset($data['default_image_url'])) {
         $prepared['default_image_url'] = $data['default_image_url'];
     }
     if (isset($data['variation_configurable_images'])) {
         $prepared['variation_configurable_images'] = $data['variation_configurable_images'];
         if (is_array($prepared['variation_configurable_images'])) {
             $prepared['variation_configurable_images'] = json_encode($prepared['variation_configurable_images']);
         }
     }
     if (isset($data['use_supersize_images'])) {
         $prepared['use_supersize_images'] = (int) $data['use_supersize_images'];
     }
     //        if (isset($data['watermark_mode'])) {
     //            $prepared['watermark_mode'] = (int)$data['watermark_mode'];
     //        }
     // ---------------------------------------
     //        $watermarkSettings = array();
     //        $hashChange = false;
     //
     //        if (isset($data['watermark_settings']['position'])) {
     //            $watermarkSettings['position'] = (int)$data['watermark_settings']['position'];
     //
     //            if (isset($data['old_watermark_settings']) &&
     //                $data['watermark_settings']['position'] != $data['old_watermark_settings']['position']) {
     //                $hashChange = true;
     //            }
     //        }
     //
     //        if (isset($data['watermark_settings']['scale'])) {
     //            $watermarkSettings['scale'] = (int)$data['watermark_settings']['scale'];
     //
     //            if (isset($data['old_watermark_settings']) &&
     //                $data['watermark_settings']['scale'] != $data['old_watermark_settings']['scale']) {
     //                $hashChange = true;
     //            }
     //        }
     //
     //        if (isset($data['watermark_settings']['transparent'])) {
     //            $watermarkSettings['transparent'] = (int)$data['watermark_settings']['transparent'];
     //
     //            if (isset($data['old_watermark_settings']) &&
     //                $data['watermark_settings']['transparent'] != $data['old_watermark_settings']['transparent']) {
     //                $hashChange = true;
     //            }
     //        }
     // ---------------------------------------
     //        if (!empty($_FILES['watermark_image']['tmp_name'])) {
     //
     //            $hashChange = true;
     //
     //            $prepared['watermark_image'] = file_get_contents($_FILES['watermark_image']['tmp_name']);
     //
     //            if (isset($prepared['id'])) {
     //
     //                $varDir = $this->modelFactory->getObject(
     //                    'VariablesDir',
     //                    array('child_folder' => 'ebay/template/description/watermarks')
     //                );
     //
     //                $watermarkPath = $varDir->getPath().(int)$prepared['id'].'.png';
     //                if (is_file($watermarkPath)) {
     //                    @unlink($watermarkPath);
     //                }
     //            }
     //
     //        } elseif (!empty($data['old_watermark_image']) && !isset($prepared['id'])) {
     //            $prepared['watermark_image'] = base64_decode($data['old_watermark_image']);
     //        }
     // ---------------------------------------
     //        if ($hashChange) {
     //            $watermarkSettings['hashes']['previous'] = $data['old_watermark_settings']['hashes']['current'];
     //            $watermarkSettings['hashes']['current'] = substr(sha1(microtime()), 0, 5);
     //        } else {
     //            $watermarkSettings['hashes']['previous'] = $data['old_watermark_settings']['hashes']['previous'];
     //            $watermarkSettings['hashes']['current'] = $data['old_watermark_settings']['hashes']['current'];
     //        }
     //
     //        $prepared['watermark_settings'] = json_encode($watermarkSettings);
     // ---------------------------------------
     return $prepared;
 }