Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce configuration script to have Google Ready shops #1429

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/autoconfig/configure_customtext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php


use PrestaShop\PrestaShop\Adapter\Module\Configuration\ModuleComplexConfigurationInterface;

class configure_customtext implements ModuleComplexConfigurationInterface
{
public function run(PrestaShop\PrestaShop\Core\Module\ModuleInterface $module, array $params)
{
$shopName = str_replace(['_', '-'], [' ', ' '], Configuration::get('PS_SHOP_NAME'));

$requestsList = [
"UPDATE ps_info_lang SET `text` = '<h2><span style=\"color: #cbb3f7\">Discover {$shopName}</span></h2>
<p>Welcome to {$shopName}, your online destination for unique and quality clothing, accessories, and home decor. We take pride in offering you a wide selection of products from different styles and trends so you can find something that suits you.</p>
<p>Whether you\'re looking for a dress for a special occasion, a handbag to complement your daily outfit, or decor items for your home, we\'ve got you covered. Our team works hard to find the most popular products of the moment and ensure that we offer quality items at affordable prices.</p>
<p>Browse our online store to discover our collection of products and find your next favorite item at {$shopName}.</p>' WHERE id_shop = 1 AND id_lang = (SELECT id_lang from ps_lang where iso_code = 'gb')",

"UPDATE ps_info_lang SET `text` = '<h2><span style=\"color: #cbb3f7\">Découvrez {$shopName}</span></h2>
<p>Bienvenue chez {$shopName}, votre destination en ligne pour des vêtements, des accessoires et de la décoration uniques et de qualité. Nous sommes fiers de vous offrir une large sélection de produits de différents styles et tendances pour que vous puissiez trouver quelque chose qui vous convient.</p>
<p>Que vous cherchiez une robe pour une occasion spéciale, un sac à main pour compléter votre tenue quotidienne ou des objets de décoration pour votre maison, nous avons ce qu\'il vous faut. Notre équipe travaille dur pour trouver les produits les plus en vogue du moment et pour s\'assurer que nous proposons des articles de qualité à des prix abordables.</p>
<p>Parcourez notre boutique en ligne pour découvrir notre collection de produits et trouvez votre prochain coup de cœur chez {$shopName}.</p>' WHERE id_shop = 1 AND id_lang = (SELECT id_lang from ps_lang where iso_code = 'fr')",

"UPDATE ps_hook_module SET position = position + 1 WHERE id_hook = (SELECT id_hook FROM `ps_hook` where `name` like \"displayHome\")",
"UPDATE ps_hook_module SET position = 0 WHERE id_hook = (SELECT id_hook FROM `ps_hook` where `name` like \"displayHome\") AND id_module = (SELECT id_module FROM ps_module WHERE `name` LIKE 'ps_customtext')",
];

$db = Db::getInstance();
foreach($requestsList as $request) {
$db->executeS($request);
}
}
}
20 changes: 20 additions & 0 deletions tests/autoconfig/configure_ps_banner.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

use PrestaShop\PrestaShop\Adapter\Module\Configuration\ModuleComplexConfigurationInterface;

class configure_ps_banner implements ModuleComplexConfigurationInterface
{
public function run(PrestaShop\PrestaShop\Core\Module\ModuleInterface $module, array $params)
{
$languages = Language::getLanguages(false);

foreach ($languages as $lang) {
$values['BANNER_LINK'][(int) $lang['id_lang']] = Context::getContext()->link->getCategoryLink(
new Category(3),
null,
$lang['id_lang']
);
}
Configuration::updateValue('BANNER_LINK', $values['BANNER_LINK']);
}
}
73 changes: 73 additions & 0 deletions tests/autoconfig/configure_ps_imageslider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

use PrestaShop\PrestaShop\Adapter\Module\Configuration\ModuleComplexConfigurationInterface;

class configure_ps_imageslider implements ModuleComplexConfigurationInterface
{
private $data = [
1 => [
'fr' => [
'idCategory' => 9,
'title' => 'DECORATION',
'description' => "<h3>Ajoutez la touche finale</h3>
<p>De l'art et de la décoration pour tous</p>",
],
'gb' => [
'idCategory' => 9,
'title' => 'ART',
'description' => '<h3>Add the final touch</h3>
<p>Art and decoration for everyone.</p>',
],
],
2 => [
'fr' => [
'idCategory' => 6,
'title' => 'ACCESSOIRES',
'description' => '<h3>Rien que pour vous</h3>
<p>Découvrez notre collection d’accessoires.</p>',
],
'gb' => [
'idCategory' => 6,
'title' => 'ACCESSORIES',
'description' => '<h3>Only for you</h3>
<p>Discover our accessories collection.</p>',
],
],
3 => [
'fr' => [
'idCategory' => 3,
'title' => 'VETEMENTS',
'description' => '<h3>Prêt-à-porter</h3>
<p>Découvrez notre collection de vêtements.</p>',
],
'gb' => [
'idCategory' => 3,
'title' => 'CLOTHING',
'description' => '<h3>Ready to wear</h3>
<p>Discover our clothing collection.</p>',
],
],
];

public function run(PrestaShop\PrestaShop\Core\Module\ModuleInterface $module, array $params)
{
include_once _PS_ROOT_DIR_ . '/modules/ps_imageslider/Ps_HomeSlide.php';

$languages = Language::getLanguages(false);
foreach ($this->data as $slideId => $slideData) {
$slide = new Ps_HomeSlide($slideId);
foreach ($languages as $language) {
$slideDataLang = $slideData[$language['iso_code']];

$slide->title[$language['id_lang']] = $slideDataLang['title'];
$slide->description[$language['id_lang']] = $slideDataLang['description'];
$slide->url[$language['id_lang']] = Context::getContext()->link->getCategoryLink(
new Category($slideDataLang['idCategory']),
null,
$language['id_lang']
);
}
$slide->save();
}
}
}
Loading