Skip to content

Commit

Permalink
feature update additional_image_link
Browse files Browse the repository at this point in the history
  • Loading branch information
zsoltoroszlany82 committed Dec 13, 2024
1 parent 76d4baf commit 3842b3d
Show file tree
Hide file tree
Showing 16 changed files with 107 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oc4_google_base",
"version": "1.0.2",
"version": "1.0.3",
"description": "Playful Sparkle - Google Base for OpenCart 4",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/admin/controller/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public function index(): void
$config = $this->model_setting_setting->getSetting('feed_ps_google_base', $store_id);

$data['feed_ps_google_base_status'] = isset($config['feed_ps_google_base_status']) ? (bool) $config['feed_ps_google_base_status'] : false;
$data['feed_ps_google_base_additional_images'] = isset($config['feed_ps_google_base_additional_images']) ? (bool) $config['feed_ps_google_base_additional_images'] : false;
$data['feed_ps_google_base_skip_out_of_stock'] = isset($config['feed_ps_google_base_skip_out_of_stock']) ? (bool) $config['feed_ps_google_base_skip_out_of_stock'] : false;
$data['feed_ps_google_base_login'] = isset($config['feed_ps_google_base_login']) ? $config['feed_ps_google_base_login'] : '';
$data['feed_ps_google_base_password'] = isset($config['feed_ps_google_base_password']) ? $config['feed_ps_google_base_password'] : '';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/cs-cz/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Sazba daně';
$_['entry_tax_ship'] = 'Doprava daně';
$_['entry_active_store'] = 'Aktivní obchod';
$_['entry_additional_images'] = 'Zahrnout další obrázky';

// Help
$_['help_copy'] = 'Zkopírovat URL';
$_['help_open'] = 'Otevřít URL';
$_['help_additional_images'] = 'Povolením této možnosti přidáte do svého Google Base feedu další obrázky. Mějte na paměti, že povolení této funkce může zpomalit proces generování feedu a zvýšit velikost generovaného XML souboru.';

// Error
$_['error_permission'] = 'Upozornění: Nemáte oprávnění upravovat Google Base feed!';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/de-de/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Steuersatz';
$_['entry_tax_ship'] = 'Versandsteuer';
$_['entry_active_store'] = 'Aktiver Shop';
$_['entry_additional_images'] = 'Zusätzliche Bilder einbeziehen';

// Help
$_['help_copy'] = 'URL kopieren';
$_['help_open'] = 'URL öffnen';
$_['help_additional_images'] = 'Das Aktivieren dieser Option fügt Ihrem Google Base-Feed zusätzliche Bilder hinzu. Beachten Sie, dass dies den Generierungsprozess des Feeds verlangsamen und die Größe der generierten XML-Datei erhöhen kann.';

// Error
$_['error_permission'] = 'Warnung: Sie haben keine Berechtigung, den Google Base Feed zu ändern!';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/en-gb/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Tax Rate';
$_['entry_tax_ship'] = 'Shipping tax';
$_['entry_active_store'] = 'Active Store';
$_['entry_additional_images'] = 'Include Additional Images';

// Help
$_['help_copy'] = 'Copy URL';
$_['help_open'] = 'Open URL';
$_['help_additional_images'] = 'Toggling this option will add additional images to your Google Base feed. Note that enabling this may slow down the feed generation process and increase the size of the generated XML file.';

// Error
$_['error_permission'] = 'Warning: You do not have permission to modify Google Base feed!';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/en-us/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Tax Rate';
$_['entry_tax_ship'] = 'Shipping tax';
$_['entry_active_store'] = 'Active Store';
$_['entry_additional_images'] = 'Include Additional Images';

// Help
$_['help_copy'] = 'Copy URL';
$_['help_open'] = 'Open URL';
$_['help_additional_images'] = 'Toggling this option will add additional images to your Google Base feed. Note that enabling this may slow down the feed generation process and increase the size of the generated XML file.';

// Error
$_['error_permission'] = 'Warning: You do not have permission to modify Google Base feed!';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/es-es/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Tasa de Impuesto';
$_['entry_tax_ship'] = 'Impuesto de Envío';
$_['entry_active_store'] = 'Tienda activa';
$_['entry_additional_images'] = 'Incluir imágenes adicionales';

// Help
$_['help_copy'] = 'Copiar URL';
$_['help_open'] = 'Abrir URL';
$_['help_additional_images'] = 'Activar esta opción añadirá imágenes adicionales a su feed de Google Base. Tenga en cuenta que habilitar esta opción puede ralentizar el proceso de generación del feed y aumentar el tamaño del archivo XML generado.';

// Error
$_['error_permission'] = 'Advertencia: ¡No tienes permiso para modificar el feed de Google Base!';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/fr-fr/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Taux de taxe';
$_['entry_tax_ship'] = 'Taxe sur l\'expédition';
$_['entry_active_store'] = 'Magasin actif';
$_['entry_additional_images'] = 'Inclure des images supplémentaires';

// Help
$_['help_copy'] = 'Copier l\'URL';
$_['help_open'] = 'Ouvrir l\'URL';
$_['help_additional_images'] = 'Activer cette option ajoutera des images supplémentaires à votre flux Google Base. Veuillez noter que cela peut ralentir le processus de génération du flux et augmenter la taille du fichier XML généré.';

// Error
$_['error_permission'] = 'Avertissement : Vous n\'avez pas l\'autorisation de modifier le flux Google Base !';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/hu-hu/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Adókulcs';
$_['entry_tax_ship'] = 'Szállítási adó';
$_['entry_active_store'] = 'Aktív áruház';
$_['entry_additional_images'] = 'További képek hozzáadása';

// Help
$_['help_copy'] = 'URL másolása';
$_['help_open'] = 'URL megnyitása';
$_['help_additional_images'] = 'Ennek az opciónak az engedélyezésével további képeket adhat hozzá a Google Base feedhez. Vegye figyelembe, hogy ez lassíthatja a feed generálási folyamatát, és növelheti a generált XML fájl méretét.';

// Error
$_['error_permission'] = 'Figyelmeztetés: Nincs jogosultsága a Google Base feed módosításához!';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/it-it/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Aliquota Fiscale';
$_['entry_tax_ship'] = 'Tassa di spedizione';
$_['entry_active_store'] = 'Negozio attivo';
$_['entry_additional_images'] = 'Includi immagini aggiuntive';

// Help
$_['help_copy'] = 'Copia URL';
$_['help_open'] = 'Apri URL';
$_['help_additional_images'] = 'Attivando questa opzione, verranno aggiunte immagini aggiuntive al feed di Google Base. Si noti che questa opzione potrebbe rallentare il processo di generazione del feed e aumentare la dimensione del file XML generato.';

// Error
$_['error_permission'] = 'Attenzione: Non hai permesso di modificare il feed di Google Base!';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/ru-ru/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Налоговая ставка';
$_['entry_tax_ship'] = 'Налог на доставку';
$_['entry_active_store'] = 'Активный магазин';
$_['entry_additional_images'] = 'Включить дополнительные изображения';

// Help
$_['help_copy'] = 'Копировать URL';
$_['help_open'] = 'Открыть URL';
$_['help_additional_images'] = 'Включение этой опции добавит дополнительные изображения в ваш фид Google Base. Обратите внимание, что это может замедлить процесс генерации фида и увеличить размер создаваемого XML-файла.';

// Error
$_['error_permission'] = 'Предупреждение: У вас нет прав для изменения ленты Google Base!';
Expand Down
6 changes: 6 additions & 0 deletions src/admin/language/sk-sk/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@
$_['entry_tax_rate'] = 'Sadzba dane';
$_['entry_tax_ship'] = 'Doprava dane';
$_['entry_active_store'] = 'Aktívny obchod';
$_['entry_additional_images'] = 'Zahrnúť ďalšie obrázky';

// Help
$_['help_copy'] = 'Skopírovať URL';
$_['help_open'] = 'Otvoriť URL';
$_['help_additional_images'] = 'Povolením tejto možnosti pridáte do svojho Google Base feedu ďalšie obrázky. Majte na pamäti, že povolenie tejto funkcie môže spomaliť proces generovania feedu a zvýšiť veľkosť generovaného XML súboru.';

// Error
$_['error_permission'] = 'Upozornenie: Nemáte oprávnenie upravovať Google Base feed!';
Expand Down
4 changes: 4 additions & 0 deletions src/admin/model/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class PSGoogleBase extends \Opencart\System\Engine\Model
*/
public function install(): void
{
$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ps_google_base_category`");

$this->db->query("
CREATE TABLE `" . DB_PREFIX . "ps_google_base_category` (
`google_base_category_id` int(11) NOT NULL,
Expand All @@ -28,6 +30,8 @@ public function install(): void
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
");

$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "ps_google_base_category_to_category`");

$this->db->query("
CREATE TABLE `" . DB_PREFIX . "ps_google_base_category_to_category` (
`google_base_category_id` int(11) NOT NULL,
Expand Down
22 changes: 21 additions & 1 deletion src/admin/view/template/feed/ps_google_base.twig
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@

</fieldset>

<div class="row mb-3">
<label for="input-additional-images" class="col-sm-2 col-form-label">{{ entry_additional_images }}</label>
<div class="col-sm-10">
<div class="form-check form-switch form-switch-lg">
<input type="hidden" name="feed_ps_google_base_additional_images" value="0">
<input type="checkbox" name="feed_ps_google_base_additional_images" value="1" id="input-additional-images" class="form-check-input" {% if feed_ps_google_base_additional_images %} checked{% endif %}>
</div>
<div class="form-text">{{ help_additional_images }}</div>
</div>
</div>

<div class="row mb-3">
<label for="input-skip-out-of-stock" class="col-sm-2 col-form-label">{{ entry_skip_out_of_stock }}</label>
<div class="col-sm-10">
Expand Down Expand Up @@ -171,7 +182,8 @@
<div class="input-group-text"><img src="{{ language.image }}" title="{{ language.name }}"></div>
<input type="text" name="data_feed_{{ language.language_id }}" value="{{ data_feed_urls[language.language_id] }}" id="input-data-feed-{{ language.language_id }}" class="form-control" readonly>
<span class="input-group-btn">
<button type="button" class="btn btn-success btn-copy" data-toggle="tooltip" data-input-id="input-data-feed-{{ language.language_id }}" title="{{ help_copy }}"><i class="fa fa-copy"></i></button>
<button type="button" class="btn btn-info btn-copy" data-toggle="tooltip" data-input-id="input-data-feed-{{ language.language_id }}" title="{{ help_copy }}"><i class="fa fa-copy"></i></button>
<button type="button" class="btn btn-light btn-open" data-toggle="tooltip" data-input-id="input-data-feed-{{ language.language_id }}" title="{{ help_open }}"><i class="fa fa-link"></i></button>
</span>
</div>
{% endfor %}
Expand Down Expand Up @@ -302,6 +314,14 @@
}
});
$('.btn-open').on('click', function () {
var linkUrl = $("#" + $(this).data('inputId')).val();
if (linkUrl.length) {
window.open(linkUrl, '_blank');
}
});
// Google Category
$('input[name=\'google_base_category\']').autocomplete({
'source': function (request, response) {
Expand Down
24 changes: 19 additions & 5 deletions src/catalog/controller/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function index(): void

$config = $this->model_setting_setting->getSetting('feed_ps_google_base', $this->config->get('config_store_id'));

$additional_images = isset($config['feed_ps_google_base_additional_images']) ? (bool) $config['feed_ps_google_base_additional_images'] : false;
$skip_out_of_stock = isset($config['feed_ps_google_base_skip_out_of_stock']) ? (bool) $config['feed_ps_google_base_skip_out_of_stock'] : false;
$base_login = isset($config['feed_ps_google_base_login']) ? $config['feed_ps_google_base_login'] : '';
$base_password = isset($config['feed_ps_google_base_password']) ? $config['feed_ps_google_base_password'] : '';
Expand Down Expand Up @@ -160,12 +161,25 @@ public function index(): void
$xml->writeElement('g:id', $product['product_id']);

// Image link
$xml->startElement('g:image_link');
if ($product['image']) {
$image_link = $this->model_tool_image->resize(html_entity_decode($product['image'], ENT_QUOTES, 'UTF-8'), $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height'));
$xml->text($image_link);
$image_link = $product['image'] ? $this->model_tool_image->resize(html_entity_decode($product['image'], ENT_QUOTES, 'UTF-8'), $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')) : null;

if ($image_link) {
$xml->startElement('g:image_link');
$xml->writeCData($image_link);
$xml->endElement();
}

if ($additional_images && $product_images = $this->model_catalog_product->getImages($product['product_id'])) {
foreach ($product_images as $product_image) {
$image_link = $product_image['image'] ? $this->model_tool_image->resize(html_entity_decode($product_image['image'], ENT_QUOTES, 'UTF-8'), $this->config->get('config_image_popup_width'), $this->config->get('config_image_popup_height')) : null;

if ($image_link) {
$xml->startElement('g:additional_image_link');
$xml->writeCData($image_link);
$xml->endElement();
}
}
}
$xml->endElement();

// Model number
$xml->writeElement('g:model_number', $product['model']);
Expand Down
2 changes: 1 addition & 1 deletion src/install.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Playful Sparkle - Google Base",
"code": "ps_google_base",
"license": "GPL",
"version": "1.0.2",
"version": "1.0.3",
"author": "Playful Sparkle",
"link": "https://github.com/playfulsparkle/oc4_google_base.git"
}

0 comments on commit 3842b3d

Please sign in to comment.