Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9777ae0
ECP-96: nb days sync could be inf at 1
Jul 16, 2024
ead6453
ECP-96: floor for nb_days
Jul 16, 2024
ba8b78f
ECP-96 floor
Jul 16, 2024
acb2446
PST-21540: Prestashop hook callable in main class
Jul 17, 2024
8de9be1
PST-21540: function params comment
Jul 17, 2024
8d6d7f9
PST-21540: lengow module hook from backend
Jul 17, 2024
973708c
PST-21540: config for disable email and order status change
Jul 19, 2024
aa06fd9
Merged in PST-21540-prestashop-hook-does-not-greff (pull request #100)
alherlengow Jul 22, 2024
d061e76
Merged in ECP-96-nb_days-1-for-prestashop (pull request #99)
alherlengow Jul 26, 2024
787e045
release-3.5.4: fix filter catalog export dor multi shop
michaelmaslengow Aug 7, 2024
73eddf9
feat(plugins): [WIP][ECP-101] fix syntax - change version
michaelmaslengow Aug 7, 2024
4ba48d8
feat(plugins): [WIP][ECP-100] Test create table by upgrade file
michaelmaslengow Aug 8, 2024
f09b712
feat(plugins): [WIP][ECP-100] Reverse values columns for lengow_expor…
michaelmaslengow Aug 8, 2024
a8bcbd1
feat(plugins): [WIP][ECP-100] fix migration
michaelmaslengow Aug 8, 2024
d337c0b
feat(plugins): [WIP][ECP-100] forget to switch
michaelmaslengow Aug 8, 2024
95c8125
feat(plugins): [WIP][ECP-100] add form to change field and values
michaelmaslengow Aug 8, 2024
b56ab58
feat(plugins): [WIP][ECP-100] add column for default key
michaelmaslengow Aug 8, 2024
200162c
feat(plugins): [WIP][ECP-100] drop table when uninstall plugin
michaelmaslengow Aug 8, 2024
7669f0e
feat(prestashop): [WIP][ECP-100] add modal for form, POST data, add b…
michaelmaslengow Aug 8, 2024
073964d
feat(prestashop): [WIP][ECP-100] add icon
michaelmaslengow Aug 8, 2024
3b7a96d
feat(plugins): [WIP][ECP-100] remove select for prestashop value - fi…
michaelmaslengow Aug 9, 2024
8bc1224
feat(plugins): [WIP][ECP-100] fix not save other key of fields
michaelmaslengow Aug 12, 2024
1ba31b2
feat(plugins): [WIP][ECP-100] add translation key
michaelmaslengow Aug 12, 2024
482ca42
feat(plugins): [WIP][ECP-100] fix wrong key for translation
michaelmaslengow Aug 12, 2024
4a7481c
feat(plugins): [WIP][ECP-100] add column exemple data, add function f…
michaelmaslengow Aug 16, 2024
7b2c327
feat(plugins): [ECP-100] add column for select fields to export - fix…
michaelmaslengow Sep 24, 2024
da90aa7
feat(plugins): [ECP-100] can select base field to export in selection…
michaelmaslengow Sep 24, 2024
12bf3e2
feat(plugins): [ECP-100] add configurable option for export feature o…
michaelmaslengow Sep 25, 2024
5b3fd08
feat(plugins): [ECP-100] add configurable option for get or not featu…
michaelmaslengow Sep 25, 2024
16c3687
feat(plugins): [ECP-100] delete dev env comment
michaelmaslengow Sep 25, 2024
5648578
feat(plugins): [ECP-100] add buttons for selection of fields to export
michaelmaslengow Sep 25, 2024
dba779b
feat(plugins): [ECP-100] fix front - remove versionning of script and…
michaelmaslengow Sep 25, 2024
3b5effd
feat(plugins): [ECP-100] modify buttons for dynamic checkbox for sele…
michaelmaslengow Sep 26, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ config_fr.xml
**/.DS_Store
config/marketplaces.json
tools/vars.sh
.php_cs.cache
.php-cs-fixer.cache
.php-cs-fixer.dist.php
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Lengow for PrestaShop

- **Requires at least:** 1.7
- **Tested up to:** 8.1.2
- **Requires at least:** 1.7.7
- **Tested up to:** 8.1.7
- **Requires PHP:** 7.4
- **Stable tag:** 3.5.3
- **Stable tag:** 3.5.4
- **License:** Apache-2.0
- **License URI:** http://www.apache.org/licenses/LICENSE-2.0

Expand Down
60 changes: 57 additions & 3 deletions classes/controllers/LengowFeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,50 @@ public function postProcess()
}
echo json_encode($data);
break;
case 'update_fields':
$fields = Tools::getValue('fields');
$exportFeatures = Tools::getValue('LENGOW_EXPORT_PRODUCT_FEATURE_ENABLED');
if ($exportFeatures === 'on') {
LengowConfiguration::updateValue(
LengowConfiguration::EXPORT_PRODUCT_FEATURE_ENABLED,
1
);
} else {
LengowConfiguration::updateValue(
LengowConfiguration::EXPORT_PRODUCT_FEATURE_ENABLED,
0
);
}
if (is_array($fields)) {
foreach ($fields as $key => $field) {
if (in_array($field['prestashop_value'], ['id', 'category', 'name', 'price_incl_tax', 'language'])) {
$field['exported'] = '1';
}
$defaultKey = $key;
$prestashopValue = isset($field['prestashop_value']) ? pSQL($field['prestashop_value']) : '';
$lengowField = isset($field['lengow_field']) ? pSQL($field['lengow_field']) : '';
$exported = isset($field['exported']) ? (int) $field['exported'] : 0;

$sql = 'SELECT COUNT(*) FROM ' . _DB_PREFIX_ . 'lengow_exported_fields WHERE default_key = "' . $defaultKey . '"';
$exists = Db::getInstance()->getValue($sql);

if ($exists) {
$sql = 'UPDATE ' . _DB_PREFIX_ . 'lengow_exported_fields
SET prestashop_value = "' . $prestashopValue . '",
lengow_field = "' . $lengowField . '",
exported = "' . $exported . '"
WHERE default_key = "' . $defaultKey . '"';
} else {
$sql = 'INSERT INTO ' . _DB_PREFIX_ . 'lengow_exported_fields (default_key, prestashop_value, lengow_field, exported)
VALUES ("' . $defaultKey . '", "' . $prestashopValue . '", "' . $lengowField . '", "' . $exported . '")';
}

Db::getInstance()->execute($sql);
}

return Tools::redirectAdmin($this->lengowLink->getAbsoluteAdminLink('AdminLengowFeed'));
}
break;
}
exit;
}
Expand All @@ -246,6 +290,10 @@ public function postProcess()
*/
public function display()
{
$lengowExport = new LengowExport();
$fields = $lengowExport->getConfigFields();
$form = new LengowConfigurationForm(['fields' => LengowConfiguration::getKeys()]);
$exportFeatures = $form->buildInputs([LengowConfiguration::EXPORT_PRODUCT_FEATURE_ENABLED]);
$shopCollection = [];
if ($currentShop = Shop::getContextShopID()) {
$results = [['id_shop' => $currentShop]];
Expand Down Expand Up @@ -292,7 +340,13 @@ public function display()
'list' => $this->buildTable($shop->id),
];
}

$productsData = $lengowExport->getProductsListData();

$this->context->smarty->assign('shopCollection', $shopCollection);
$this->context->smarty->assign('fields', $fields);
$this->context->smarty->assign('json_products', $productsData);
$this->context->smarty->assign('export_features', $exportFeatures);
parent::display();
}

Expand Down Expand Up @@ -531,9 +585,9 @@ class="lgw-btn lengow_add_to_export">
$html .= '<div class="lengow_select_all_shop lgw-container" style="display:none;">';
$html .= '<input type="checkbox" id="select_all_shop_' . $idShop . '"/>&nbsp;&nbsp;';
$html .= '<span>' . $this->locale->t(
'product.screen.select_all_products',
['nb' => $this->list->getTotal()]
);
'product.screen.select_all_products',
['nb' => $this->list->getTotal()]
);
$html .= '</span>';
$html .= '</div>';
$html .= '</div>';
Expand Down
2 changes: 2 additions & 0 deletions classes/controllers/LengowOrderSettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function display()
LengowConfiguration::SHIPPED_ORDER_ID,
LengowConfiguration::CANCELED_ORDER_ID,
LengowConfiguration::SHIPPED_BY_MARKETPLACE_ORDER_ID,
LengowConfiguration::SEND_EMAIL_DISABLED
]
);
$importParams = $form->buildInputs(
Expand Down Expand Up @@ -184,3 +185,4 @@ public function postProcess()
}
}
}

33 changes: 32 additions & 1 deletion classes/models/LengowConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class LengowConfiguration extends Configuration
public const LAST_UPDATE_PLUGIN_DATA = 'LENGOW_PLUGIN_DATA_UPDATE';
public const LAST_UPDATE_AUTHORIZATION_TOKEN = 'LENGOW_LAST_AUTH_TOKEN_UPDATE';
public const LAST_UPDATE_PLUGIN_MODAL = 'LENGOW_LAST_PLUGIN_MODAL';
public const SEND_EMAIL_DISABLED = 'LENGOW_SEND_EMAIL_DISABLED';
public const EXPORT_PRODUCT_FEATURE_ENABLED = 'LENGOW_EXPORT_PRODUCT_FEATURE_ENABLED';

/* Configuration parameters */
public const PARAM_COLLECTION = 'collection';
Expand All @@ -107,6 +109,7 @@ class LengowConfiguration extends Configuration
public const RETURN_TYPE_INTEGER = 'integer';
public const RETURN_TYPE_ARRAY = 'array';
public const RETURN_TYPE_STRING = 'string';
public const RETURN_TYPE_FLOAT = 'float';

/**
* @var array params correspondence keys for toolbox
Expand Down Expand Up @@ -168,6 +171,8 @@ class LengowConfiguration extends Configuration
self::LAST_UPDATE_PLUGIN_DATA => 'last_update_plugin_data',
self::LAST_UPDATE_AUTHORIZATION_TOKEN => 'last_update_authorization_token',
self::LAST_UPDATE_PLUGIN_MODAL => 'last_update_plugin_modal',
self::SEND_EMAIL_DISABLED => 'send_email_disabled',
self::EXPORT_PRODUCT_FEATURE_ENABLED => 'export_product_feature_enabled',
];

/**
Expand Down Expand Up @@ -436,7 +441,7 @@ public static function getKeys($key = null)
self::PARAM_LABEL => $locale->t('lengow_setting.lengow_import_days_title'),
self::PARAM_DEFAULT_VALUE => 3,
self::PARAM_UPDATE => true,
self::PARAM_RETURN => self::RETURN_TYPE_INTEGER,
self::PARAM_RETURN => self::RETURN_TYPE_FLOAT,
],
self::ANONYMIZE_EMAIL => [
self::PARAM_TYPE => LengowConfigurationForm::TYPE_CHECKBOX,
Expand Down Expand Up @@ -575,6 +580,19 @@ public static function getKeys($key = null)
self::PARAM_GLOBAL => true,
self::PARAM_RETURN => self::RETURN_TYPE_INTEGER,
],
self::SEND_EMAIL_DISABLED => [
self::PARAM_TYPE => LengowConfigurationForm::TYPE_CHECKBOX,
self::PARAM_GLOBAL => true,
self::PARAM_RETURN => self::RETURN_TYPE_BOOLEAN,
self::PARAM_LABEL => $locale->t('lengow_setting.lengow_disable_send_email_title'),
self::PARAM_LEGEND => $locale->t('lengow_setting.lengow_disable_send_email_legend'),
],
self::EXPORT_PRODUCT_FEATURE_ENABLED => [
self::PARAM_TYPE => LengowConfigurationForm::TYPE_CHECKBOX,
self::PARAM_GLOBAL => true,
self::PARAM_RETURN => self::RETURN_TYPE_BOOLEAN,
self::PARAM_LABEL => "Export product feature",
],
];
}

Expand Down Expand Up @@ -1000,6 +1018,16 @@ public static function isProductionMode()
return self::getPluginEnvironment() === 'prod';
}

/**
* Will return the global the typed global value
* @return mixed
*/
public static function getTypedGlobalValue($key)
{
$value = self::get($key);
return self::getValueWithCorrectType($key, $value);
}

/**
* Get configuration value in correct type
*
Expand All @@ -1023,9 +1051,12 @@ private static function getValueWithCorrectType($key, $value = null)
: [];
case self::RETURN_TYPE_STRING:
return (string) $value;
case self::RETURN_TYPE_FLOAT:
return (float) $value;
}
}

return $value;
}
}

Loading