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 3ff2842 commit 377ece1
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oc3_google_base",
"version": "1.0.2",
"version": "1.0.3",
"description": "Playful Sparkle - Google Base for OpenCart 3",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/install.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ code package and also available on the project page: https://github.com/playfuls
<modification>
<name>Playful Sparkle - Google Base</name>
<code>ps_google_base</code>
<version>1.0.2</version>
<version>1.0.3</version>
<author>Playful Sparkle</author>
<link>https://github.com/playfulsparkle/oc3_google_base.git</link>
</modification>
6 changes: 6 additions & 0 deletions src/upload/admin/controller/extension/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ public function index()
$data['feed_ps_google_base_status'] = (bool) $this->model_setting_setting->getSettingValue('feed_ps_google_base_status', $store_id);
}

if (isset($this->request->post['feed_ps_google_base_additional_images'])) {
$data['feed_ps_google_base_additional_images'] = (bool) $this->request->post['feed_ps_google_base_additional_images'];
} else {
$data['feed_ps_google_base_additional_images'] = (bool) $this->model_setting_setting->getSettingValue('feed_ps_google_base_additional_images', $store_id);
}

if (isset($this->request->post['feed_ps_google_base_skip_out_of_stock'])) {
$data['feed_ps_google_base_skip_out_of_stock'] = (bool) $this->request->post['feed_ps_google_base_skip_out_of_stock'];
} else {
Expand Down
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
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
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
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
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
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
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
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
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
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/upload/admin/model/extension/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class ModelExtensionFeedPSGoogleBase extends Model
*/
public function install()
{
$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 AUTO_INCREMENT,
Expand All @@ -22,6 +24,8 @@ public function install()
) 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
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@

</fieldset>

<div class="form-group">
<label for="input-additional-images" class="col-sm-2 control-label">{{ entry_additional_images }}</label>
<div class="col-sm-10">
<select name="feed_ps_google_base_additional_images" id="input-additional-images" class="form-control">
{% if feed_ps_google_base_additional_images %}
<option value="1" selected="selected">{{ text_enabled }}</option>
<option value="0">{{ text_disabled }}</option>
{% else %}
<option value="1">{{ text_enabled }}</option>
<option value="0" selected="selected">{{ text_disabled }}</option>
{% endif %}
</select>
<div class="help-block text-muted">{{ help_additional_images }}</div>
</div>
</div>

<div class="form-group">
<label for="input-skip-out-of-stock" class="col-sm-2 control-label">{{ entry_skip_out_of_stock }}</label>
<div class="col-sm-10">
Expand Down Expand Up @@ -189,7 +205,8 @@
<span class="input-group-addon"><img src="language/{{ language.code }}/{{ language.code }}.png" title="{{ language.name }}"></span>
<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 @@ -332,6 +349,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
36 changes: 27 additions & 9 deletions src/upload/catalog/controller/extension/feed/ps_google_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function index()
$base_tax_definitions = (array) json_decode((string) $base_tax_definitions, true);
}

$additional_images = (bool) $this->model_setting_setting->getSettingValue('feed_ps_google_base_additional_images', $this->config->get('config_store_id'));
$skip_out_of_stock = (bool) $this->model_setting_setting->getSettingValue('feed_ps_google_base_skip_out_of_stock', $this->config->get('config_store_id'));

if ($base_login && $base_password) {
Expand Down Expand Up @@ -142,16 +143,33 @@ public function index()
$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('theme_' . $this->config->get('config_theme') . '_image_popup_width'),
$this->config->get('theme_' . $this->config->get('config_theme') . '_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('theme_' . $this->config->get('config_theme') . '_image_popup_width'),
$this->config->get('theme_' . $this->config->get('config_theme') . '_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->getProductImages($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('theme_' . $this->config->get('config_theme') . '_image_popup_width'),
$this->config->get('theme_' . $this->config->get('config_theme') . '_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

0 comments on commit 377ece1

Please sign in to comment.