Skip to content

Commit

Permalink
more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Feb 29, 2024
1 parent bc72d70 commit c283ab8
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 78 deletions.
122 changes: 44 additions & 78 deletions upload/admin/model/localisation/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ public function addLanguage(array $data): int {
$results = $this->model_catalog_attribute_group->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($results as $attribute_group) {
$this->model_catalog_attribute->addDescription($attribute['attribute_id'], $language_id, $attribute_group);
$this->model_catalog_attribute_group->addDescription($attribute['attribute_id'], $language_id, $attribute_group);
}

// Banner
$this->load->model('design/banner');

$results = $this->model_design_banner->getDescriptionsByLanguageId($this->config->get('config_language_id'));
$results = $this->model_design_banner->getImagesByLanguageId($this->config->get('config_language_id'));

foreach ($results as $banner_image) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "banner_image` SET `banner_id` = '" . (int)$banner_image['banner_id'] . "', `language_id` = '" . (int)$language_id . "', `title` = '" . $this->db->escape($banner_image['title']) . "', `link` = '" . $this->db->escape($banner_image['link']) . "', `image` = '" . $this->db->escape($banner_image['image']) . "', `sort_order` = '" . (int)$banner_image['sort_order'] . "'");
$this->model_design_banner->addImage($attribute['attribute_id'], $language_id, $banner_image);
}

// Category
Expand All @@ -53,18 +53,16 @@ public function addLanguage(array $data): int {
$results = $this->model_catalog_category->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($results as $category) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "category_description` SET `category_id` = '" . (int)$category['category_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($category['name']) . "', `description` = '" . $this->db->escape($category['description']) . "', `meta_title` = '" . $this->db->escape($category['meta_title']) . "', `meta_description` = '" . $this->db->escape($category['meta_description']) . "', `meta_keyword` = '" . $this->db->escape($category['meta_keyword']) . "'");
$this->model_catalog_category->addDescription($category['category_id'], $language_id, $category);
}

// Customer Group
$this->load->model('customer/customer_group');

$results = $this->model_customer_customer_group->getDescriptionsByLanguageId($this->config->get('config_language_id'));

$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "customer_group_description` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");

foreach ($results as $customer_group) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "customer_group_description` SET `customer_group_id` = '" . (int)$customer_group['customer_group_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($customer_group['name']) . "', `description` = '" . $this->db->escape($customer_group['description']) . "'");
$this->model_customer_customer_group->addDescription($customer_group['customer_group_id'], $language_id, $customer_group);
}

// Custom Field
Expand All @@ -73,14 +71,14 @@ public function addLanguage(array $data): int {
$results = $this->model_customer_custom_field->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($results as $custom_field) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "custom_field_description` SET `custom_field_id` = '" . (int)$custom_field['custom_field_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($custom_field['name']) . "'");
$this->model_customer_custom_field->addDescription($custom_field['custom_field_id'], $language_id, $custom_field);
}

// Custom Field Value
$results = $this->model_customer_custom_field->getValueDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($results as $custom_field_value) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "custom_field_value_description` SET `custom_field_value_id` = '" . (int)$custom_field_value['custom_field_value_id'] . "', `language_id` = '" . (int)$language_id . "', `custom_field_id` = '" . (int)$custom_field_value['custom_field_id'] . "', `name` = '" . $this->db->escape($custom_field_value['name']) . "'");
$this->model_customer_custom_field->addValueDescription($custom_field_value['custom_field_value_id'], $language_id, $custom_field_value);
}

// Download
Expand All @@ -89,7 +87,7 @@ public function addLanguage(array $data): int {
$results = $this->model_catalog_download->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($results as $download) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "download_description` SET `download_id` = '" . (int)$download['download_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($download['name']) . "'");
$this->model_catalog_download->addDescription($download['download_id'], $language_id, $download);
}

// Filter
Expand All @@ -98,7 +96,7 @@ public function addLanguage(array $data): int {
$results = $this->model_catalog_filter->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($results as $filter) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "filter_description` SET `filter_id` = '" . (int)$filter['filter_id'] . "', `language_id` = '" . (int)$language_id . "', `filter_group_id` = '" . (int)$filter['filter_group_id'] . "', `name` = '" . $this->db->escape($filter['name']) . "'");
$this->model_catalog_filter->addDescription($filter['filter_id'], $language_id, $filter);
}

// Filter Group
Expand All @@ -107,7 +105,7 @@ public function addLanguage(array $data): int {
$results = $this->model_catalog_filter_group->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($results as $filter_group) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "filter_group_description` SET `filter_group_id` = '" . (int)$filter_group['filter_group_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($filter_group['name']) . "'");
$this->model_catalog_filter_group->addDescription($filter_group['filter_group_id'], $language_id, $filter_group);
}

// Information
Expand All @@ -116,16 +114,16 @@ public function addLanguage(array $data): int {
$results = $this->model_catalog_information->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($results as $information) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "information_description` SET `information_id` = '" . (int)$information['information_id'] . "', `language_id` = '" . (int)$language_id . "', `title` = '" . $this->db->escape($information['title']) . "', `description` = '" . $this->db->escape($information['description']) . "', `meta_title` = '" . $this->db->escape($information['meta_title']) . "', `meta_description` = '" . $this->db->escape($information['meta_description']) . "', `meta_keyword` = '" . $this->db->escape($information['meta_keyword']) . "'");
$this->model_catalog_information->addDescription($information['information_id'], $language_id, $information);
}

// Length
$this->load->model('localisation/length_class');

$results = $this->model_localisation_length_class->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($query->rows as $length) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "length_class_description` SET `length_class_id` = '" . (int)$length['length_class_id'] . "', `language_id` = '" . (int)$language_id . "', `title` = '" . $this->db->escape($length['title']) . "', `unit` = '" . $this->db->escape($length['unit']) . "'");
foreach ($results as $length) {
$this->model_localisation_length_class->addDescription($length['length_class_id'], $language_id, $length);
}

// Option
Expand All @@ -138,138 +136,115 @@ public function addLanguage(array $data): int {
}

// Option Value
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "option_value_description` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");

$results = $this->model_catalog_option->getValueDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($query->rows as $option_value) {
foreach ($results as $option_value) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "option_value_description` SET `option_value_id` = '" . (int)$option_value['option_value_id'] . "', `language_id` = '" . (int)$language_id . "', `option_id` = '" . (int)$option_value['option_id'] . "', `name` = '" . $this->db->escape($option_value['name']) . "'");
}

// Order Status
$this->load->model('localisation/order_status');

$results = $this->model_
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_status` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");
$results = $this->model_localisation_order_status->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($query->rows as $order_status) {
foreach ($results as $order_status) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_status` SET `order_status_id` = '" . (int)$order_status['order_status_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($order_status['name']) . "'");
}


// Product
$this->load->model('catalog/product');

$results = $this->model_
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "product_description` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");
$results = $this->model_catalog_product->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($query->rows as $product) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "product_description` SET `product_id` = '" . (int)$product['product_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($product['name']) . "', `description` = '" . $this->db->escape($product['description']) . "', `tag` = '" . $this->db->escape($product['tag']) . "', `meta_title` = '" . $this->db->escape($product['meta_title']) . "', `meta_description` = '" . $this->db->escape($product['meta_description']) . "', `meta_keyword` = '" . $this->db->escape($product['meta_keyword']) . "'");
foreach ($results as $product) {
$this->model_catalog_product->addDescription($product['product_id'], $language_id, $product);
}


// Product Attribute
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "product_attribute` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");
$results = $this->model_catalog_product->getAttributesByLanguageId($this->config->get('config_language_id'));

$results = $this->model_

foreach ($query->rows as $product_attribute) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "product_attribute` SET `product_id` = '" . (int)$product_attribute['product_id'] . "', `attribute_id` = '" . (int)$product_attribute['attribute_id'] . "', `language_id` = '" . (int)$language_id . "', `text` = '" . $this->db->escape($product_attribute['text']) . "'");
foreach ($results as $product_attribute) {
$this->model_catalog_product->addAttribute($product_attribute['product_id'], $language_id, $product_attribute);
}

// Return Action
$this->load->model('localisation/return_action');

$results = $this->model_

$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "return_action` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");
$results = $this->model_localisation_return_action->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($query->rows as $return_action) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "return_action` SET `return_action_id` = '" . (int)$return_action['return_action_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($return_action['name']) . "'");
foreach ($results as $return_action) {
$this->model_localisation_return_action->addDescription($return_action['return_action_id'], $language_id, $return_action);
}

// Return Reason
$this->load->model('localisation/return_reason');

$results = $this->model_
$results = $this->model_localisation_return_reason->getDescriptionsByLanguageId($this->config->get('config_language_id'));

$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "return_reason` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");

foreach ($query->rows as $return_reason) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "return_reason` SET `return_reason_id` = '" . (int)$return_reason['return_reason_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($return_reason['name']) . "'");
foreach ($results as $return_reason) {
$this->model_localisation_return_reason->addDescription($return_reason['return_reason_id'], $language_id, $return_reason);
}

// Return Status
$this->load->model('localisation/return_status');

$results = $this->model_
$results = $this->model_localisation_return_status->getDescriptionsByLanguageId($this->config->get('config_language_id'));

$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "return_status` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");

foreach ($query->rows as $return_status) {
foreach ($results as $return_status) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "return_status` SET `return_status_id` = '" . (int)$return_status['return_status_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($return_status['name']) . "'");
}

// Stock Status
$this->load->model('localisation/stock_status');

$results = $this->model_localisation_stock_status->getDescriptionsByLanguageId($language_id);
$results = $this->model_localisation_stock_status->getDescriptionsByLanguageId($this->config->get('config_language_id'));

$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "stock_status` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");

foreach ($query->rows as $stock_status) {
foreach ($results as $stock_status) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "stock_status` SET `stock_status_id` = '" . (int)$stock_status['stock_status_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($stock_status['name']) . "'");
}



// Voucher Theme
$this->load->model('localisation/voucher_theme');

$results = $this->model_localisation_voucher_theme->getDescriptionsByLanguageId($language_id);

$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "voucher_theme_description` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");
$results = $this->model_localisation_voucher_theme->getDescriptionsByLanguageId($this->config->get('config_language_id'));

foreach ($query->rows as $voucher_theme) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "voucher_theme_description` SET `voucher_theme_id` = '" . (int)$voucher_theme['voucher_theme_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($voucher_theme['name']) . "'");
foreach ($results as $voucher_theme) {
$this->model_localisation_voucher_theme->addDescription($voucher_theme['voucher_theme_id'], $language_id, $voucher_theme);
}



// Weight Class
$this->load->model('localisation/weight_class');

$results = $this->model_localisation_weight_class->getDescriptionsByLanguageId($language_id);
$results = $this->model_localisation_weight_class->getDescriptionsByLanguageId($this->config->get('config_language_id'));

$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "weight_class_description` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");

foreach ($query->rows as $weight_class) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "weight_class_description` SET `weight_class_id` = '" . (int)$weight_class['weight_class_id'] . "', `language_id` = '" . (int)$language_id . "', `title` = '" . $this->db->escape($weight_class['title']) . "', `unit` = '" . $this->db->escape($weight_class['unit']) . "'");
foreach ($results as $weight_class) {
$this->model_localisation_weight_class->addDescription($weight_class['weight_class_id'], $language_id, $weight_class);
}



// Subscription
$this->load->model('localisation/subscription_status');

$results = $this->model_localisation_subscription_status->getDescriptionsByLanguageId($language_id);
$results = $this->model_localisation_subscription_status->getDescriptionsByLanguageId($this->config->get('config_language_id'));

$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "subscription_status` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");

foreach ($query->rows as $subscription) {
foreach ($results as $subscription) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "subscription_status` SET `subscription_status_id` = '" . (int)$subscription['subscription_status_id'] . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($subscription['name']) . "'");
}

// SEO URL
$this->load->model('design/seo_url');

$results = $this->model_


$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");
$results = $this->model_design_seo_url->getSeoUrlsByLanguageId($this->config->get('config_language_id'));

foreach ($query->rows as $seo_url) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "seo_url` SET `store_id` = '" . (int)$seo_url['store_id'] . "', `language_id` = '" . (int)$language_id . "', `key` = '" . $this->db->escape($seo_url['key']) . "', `value` = '" . $this->db->escape($seo_url['value']) . "', `keyword` = '" . $this->db->escape($seo_url['keyword']) . "', `sort_order` = '" . (int)$seo_url['sort_order'] . "'");
foreach ($results as $seo_url) {
$this->model_design_seo_url->addSeoUrl($seo_url['key'], $seo_url['value'], $seo_url['keyword'], $seo_url['store_id'], $language_id, $seo_url['sort_order']);
}

return $language_id;
Expand Down Expand Up @@ -530,16 +505,7 @@ public function getLanguages(array $data = []): array {
$image .= 'extension/' . $result['extension'] . '/catalog/';
}

$language_data[$result['code']] = [
'language_id' => $result['language_id'],
'name' => $result['name'],
'code' => $result['code'],
'image' => $image . 'language/' . $result['code'] . '/' . $result['code'] . '.png',
'locale' => $result['locale'],
'extension' => $result['extension'],
'sort_order' => $result['sort_order'],
'status' => $result['status']
];
$language_data[$result['code']] = $result + ['image' => $image . 'language/' . $result['code'] . '/' . $result['code'] . '.png'];
}

return $language_data;
Expand Down
13 changes: 13 additions & 0 deletions upload/admin/model/localisation/order_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ public function getDescriptions(int $order_status_id): array {
return $order_status_data;
}

/**
* Get Descriptions By Language ID
*
* @param int $language_id
*
* @return array<int, array<string, mixed>>
*/
public function getDescriptionsByLanguageId(int $language_id): array {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order_status` WHERE `language_id` = '" . (int)$language_id . "'");

return $query->rows;
}

/**
* Get Total Order Statuses
*
Expand Down
Loading

0 comments on commit c283ab8

Please sign in to comment.