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

Refacto AdminImportControllerCore #8122

Closed
wants to merge 12 commits into from
Closed

Refacto AdminImportControllerCore #8122

wants to merge 12 commits into from

Conversation

LittleBigDev
Copy link
Contributor

@LittleBigDev LittleBigDev commented Jul 11, 2017

Questions Answers
Branch? develop
Description? Refactoring AdminImportControllerCore code.
Type? improvement
Category? BO
BC breaks? no
Deprecations? no
Fixed ticket? N/A
How to test? N/A

This change is Reviewable

@prestonBot
Copy link
Collaborator

Hello LittleBigDev!

This is your first pull request on the PrestaShop project. Thank you, and welcome to this Open Source community!

@LittleBigDev LittleBigDev changed the title - Fixed bug where store contact data was not entirely imported (csv import feature) Fixed bug where store contact data was not entirely imported (csv import feature) Jul 11, 2017
@LittleBigDev
Copy link
Contributor Author

To reviewers : bug was fixed by return $line_count in AdminImportController.php line 3701. Everything else is code cleaning / refactoring.

@PrestaShop PrestaShop deleted a comment from prestonBot Jul 11, 2017
@LittleBigDev LittleBigDev reopened this Jul 11, 2017
@LittleBigDev
Copy link
Contributor Author

Fixed :)

Copy link
Member

@Quetzacoalt91 Quetzacoalt91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to refacto / clean, all comments are made regarding this task.

However, some changes were not easy to understand. In my opinion, we need more tests prior merge.

if (!(AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate))) {
$this->warnings[] = $store->image.' '.$this->trans('cannot be copied.', array(), 'Admin.Advparameters.Notification');
if (!empty($store->image)) {
$imgWasCopied = AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the value is not used on another line, no need to store it in a variable. The previous version was correct in my opinion.

Copy link
Contributor Author

@LittleBigDev LittleBigDev Jul 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was done to enhance readability of the code. AdminImportController::copyImg() return value was unclear.

$imgWasCopied = AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate);
if (!$imgWasCopied) {
$this->warnings[] = $store->image . ' '
. $this->trans('cannot be copied.', [], 'Admin.Advparameters.Notification');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @AlexEven

If we mix refacto and bug fix in this PR, it would be great to make $store->image as a variable in the translated message. It may be not available on the beginning of the string in some language. However, this means we cannot merge it for 1.7.2.x if 1.7.2.0 is released.

Copy link
Contributor

@xBorderie xBorderie Jul 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm that we'd rather have
'%1 cannot be copied (or some equivalent)
than
$img . ' ' . ' cannot be copied'.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And yeah, if the PR introduces string changes, it's kinda late in the 1.7.2.x game, and might force the PR to be moved to 1.7.3.x...

Copy link
Contributor Author

@LittleBigDev LittleBigDev Jul 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer too but it would be outside BOOM-294's scope.
I'm ok to fix this in another PR (this is not the only one that would need a fix).

$storeId = isset($info['id']) ? (int)$info['id'] : null;
$store = new Store($storeId);

$store->force_id = (bool)$forceIds;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happen for $force_ids and Store::existsInDatabase(...)?

You should explain why you changed the tests, because after a quick look this is unclear. If we want to refacto it without modifying the test cases, I would have written i.e:

if (!empty($info['id']) && ($force_ids || Store::existsInDatabase((int)$info['id'], 'store'))) {
       $storeId = (int)$info['id'];
} else {
       $storeId = null;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this code block is redundant with Store and ObjectModel constructors' logic :

  • passing empty or unknown id will lead to an unloaded Store object
  • $force_ids is used only when Store::add() is executed and has no meaning when we need to decide whether we pass an id to the constructor or not.


// If errors, log them and stop execution
if (true !== $fieldsValidationResult || true !== $langFieldsValidationResult) {
$errorGenericMessage = $this->trans('Store is invalid', [], 'Admin.Advparameters.Notification');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[] --> array()

);
}
} else {
$this->errors[] = $this->trans('Store is invalid', array(), 'Admin.Advparameters.Notification').' ('.$store->name.')';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexEven, aren't we supposed to add ('.$store->name.') in the translated string as a variable? This could be the occasion to update this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too late for 1.7.2 :(

Copy link
Contributor Author

@LittleBigDev LittleBigDev Jul 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. Should I change this couple of translations in this PR ?
Edit : according to Maxime's comment, I won't fix it here.

// If nothing worked, log an error
if (!$res) {
$this->errors[] = Db::getInstance()->getMsgError() . ' '
. sprintf(
$this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Advparameters.Notification'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While we refacto stuff, it would be great to not use sprintf for a translated string, but insert $info['name'] and ($store->id ? $store->id : 'null') in the second parameter of trans instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In progress...


// If store doesn't exist or update failed
if (!$res) {
$store->force_id = (bool)$forceIds;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be a duplicate of line 3724

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I forgot to remove it here.


$res = false;
if ($store->storeExists($store->id)) {
$res = $store->update();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would save() help you? It handles both update() and add() whether it exists or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it would. Should I fix this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a look at ObjectModel::save() method and behavior is slightly different.
ObjectModel::save() only checks if an id is present and if so, ObjectModel::update() is called.
Our code explicitely checks in DB if this is a known id. I'm ok to use ObjectModel::save(), but I need your feedback before.

@marionf marionf added the Waiting for QA Status: action required, waiting for test feedback label Jul 11, 2017
@aleeks
Copy link
Contributor

aleeks commented Jul 12, 2017

@LittleBigDev I put your PR in develop branch, we can just include this one to 1.7.2.x now.
Can you create a PR in 1.7.2.x with just the fix please ?

Edit: you need to rebase this one 😄 too

@aleeks aleeks changed the base branch from 1.7.2.x to develop July 12, 2017 15:09
@prestonBot prestonBot added Waiting for wording Status: action required, waiting for wording Report on StarterTheme labels Jul 12, 2017
@aleeks aleeks removed Report on StarterTheme Waiting for wording Status: action required, waiting for wording labels Jul 12, 2017
@LittleBigDev LittleBigDev changed the title Fixed bug where store contact data was not entirely imported (csv import feature) Refacto AdminImportControllerCore Jul 12, 2017
@prestonBot prestonBot added Waiting for wording Status: action required, waiting for wording Report on StarterTheme labels Jul 12, 2017
@aleeks aleeks removed Report on StarterTheme Waiting for wording Status: action required, waiting for wording labels Jul 12, 2017
@LittleBigDev LittleBigDev changed the title Refacto AdminImportControllerCore WIP: Refacto AdminImportControllerCore Jul 13, 2017
@prestonBot prestonBot added the Waiting for wording Status: action required, waiting for wording label Jul 13, 2017
Copy link
Member

@eternoendless eternoendless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this refacto! There are many little things to fix :)

@@ -64,6 +64,8 @@ class ManufacturerCore extends ObjectModel
/** @var bool active */
public $active;

public $shop;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't forget to add PHPDoc if you know what this property contains.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in next commit.

'Attribute (Name:Type:Position)',
array(),
'Admin.Advparameters.Feature'
) . '*',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Symfony standards say:

Add a single space around binary operators (==, &&, ...), with the exception of the concatenation (.) operator;

So unfortunately you need to remove the spaces around the . operator.

See: http://symfony.com/doc/current/contributing/code/standards.html#structure

@@ -559,12 +855,14 @@ public function __construct()
}
}

$this->separator = ($separator = Tools::substr(strval(trim(Tools::getValue('separator'))), 0, 1)) ? $separator : ';';
$separator = Tools::substr(strval(trim(Tools::getValue('separator'))), 0, 1);
$this->separator = $separator ? $separator : ';';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Watch it, you wrote two spaces after :

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in next commit.

$this->convert = false;
$this->multiple_value_separator = ($separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator'))), 0, 1)) ? $separator : ',';
$separator = Tools::substr(strval(trim(Tools::getValue('multiple_value_separator'))), 0, 1);
$this->multiple_value_separator = $separator ? $separator : ',';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in next commit.

@@ -652,14 +959,18 @@ public function renderForm()
$last = strtolower($post_max_size[strlen($post_max_size) - 1]);

switch ($last) {

/** @noinspection PhpMissingBreakStatementInspection */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need this if your case ends with a comment

', false);
$datas = Db::getInstance()->getRow(
'SELECT p.`id_product` '
. 'FROM `' . _DB_PREFIX_ . 'product` p ' . Shop::addSqlAssociation('product', 'p')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leading space before FROM

* @param $notUsed : Not used anymore.
* @param bool $regenerate : If images should be regenerated
* @param bool $forceIds : If passed store id should be used for store creation
* @param bool $validateOnly : If set to true, store will not be updated nor created with $info data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When writing PHPDoc, please don't use a separator between the variable name and the description

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

$this->errors[] = ($field_error !== true ? $field_error : '').(isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '').
Db::getInstance()->getMsgError();
if ($fieldsValidationResult !== true
|| isset($langFieldsValidationResult) && $langFieldsValidationResult !== true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please wrap isset($langFieldsValidationResult) && $langFieldsValidationResult !== true with parentheses for clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • && is prevalent on ||
  • I created a new line for this group
  • but ok, I'll change this in next commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -4078,7 +5147,8 @@ protected function supplyOrdersDetailsImportOne($info, &$products, &$reset, $for
IFNULL(pa.upc, IFNULL(p.upc, \'\')) as upc
');
$query->from('product', 'p');
$query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product AND id_product_attribute = '.(int)$id_product_attribute);
$query->leftJoin('product_attribute', 'pa', 'pa.id_product = p.id_product AND id_product_attribute = '
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the line is too long, I'd prefer if it was broken up by arguments (one per line).

@@ -4224,7 +5294,8 @@ protected function truncateTables($case)
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'specific_price_priority`');
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'product_carrier`');
Db::getInstance()->execute('TRUNCATE TABLE `'._DB_PREFIX_.'cart_product`');
if (count(Db::getInstance()->executeS('SHOW TABLES LIKE \''._DB_PREFIX_.'favorite_product\' '))) { //check if table exist
//check if table exist before truncate
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"table exists" 😉

@@ -52,6 +52,9 @@ class ProductCore extends ObjectModel
/** @var int default Category id */
public $id_category_default;

/** @var array */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @LittleBigDev
I've no idea of the context, just an alert, is it really array ?

Copy link
Contributor Author

@LittleBigDev LittleBigDev Jul 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is. Have a look at this line in AdminImportController.

'help' => $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', array(), 'Admin.Advparameters.Help'),
'help' => $this->trans(
'Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, '
. 'the default shop will be used.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't split a translatable string like that, the parser will fail.
Please, remove the concatenation even if you did it for the line length.

'meta_title' => array('label' => $this->trans('Meta title', array(), 'Admin.Global')),
'meta_keywords' => array('label' => $this->trans('Meta keywords', array(), 'Admin.Global')),
'meta_description' => array('label' => $this->trans('Meta description', array(), 'Admin.Global')),
'image' => array('label' => $this->trans('Image URL', array(), 'Admin.Advparameters.Feature')),
'shop' => array(
'label' => $this->trans('ID / Name of group shop', array(), 'Admin.Advparameters.Feature'),
'help' => $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', array(), 'Admin.Advparameters.Help'),
'help' => $this->trans(
'Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't split a translatable string like that, the parser will fail.
Please, remove the concatenation even if you did it for the line length.

'image' => array('label' => $this->trans('Image URL', array(), 'Admin.Advparameters.Feature')),
'shop' => array(
'label' => $this->trans('ID / Name of shop', array(), 'Admin.Advparameters.Feature'),
'help' => $this->trans('Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, the default shop will be used.', array(), 'Admin.Advparameters.Help'),
'help' => $this->trans(
'Ignore this field if you don\'t use the Multistore tool. If you leave this field empty, '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't split a translatable string like that, the parser will fail.
Please, remove the concatenation even if you did it for the line length.

<code>php_value post_max_size 20M</code> '.
$this->trans('(click to open "Generators" page)', array(), 'Admin.Advparameters.Notification').'</a>';
$uploadErrorMessage = $this->trans(
'The uploaded file exceeds the post_max_size directive in php.ini. If your server '
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't split a translatable string like that, the parser will fail.
Please, remove the concatenation even if you did it for the line length.

Copy link
Member

@Quetzacoalt91 Quetzacoalt91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It stopped during the review to avoid spam.

It would be great to give names to the placeholders in translated strings. This is important to give a context to the translator, and may help us to remove the duplicated strings (started in #7840).

'available_fields' => $this->getAvailableFields(),
'truncateAuthorized' => (Shop::isFeatureActive() && $this->context->employee->isSuperAdmin()) || !Shop::isFeatureActive(),
'truncateAuthorized' => !(Shop::isFeatureActive()) || $this->context->employee->isSuperAdmin(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parentheses around Shop::isFeatureActive() can be removed

|| $category->parent == $categoryId
) {
$this->errors[] = $this->trans('The category ID must be unique. It can\'t be the same as the one for the parent category (ID: %1$s).',
array($categoryId ? $categoryId : 'null'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using a placeholder with the Symfony translator, your must name them (https://symfony.com/doc/current/components/translation/usage.html#message-placeholders). Then you affect this name a variable to be replaced in the translated string.

Here is the correct syntax to translate this string:

$this->errors[] = $this->trans('The category ID must be unique. It can\'t be the same as the one for the parent category (ID: %id%).',
    array('%id%' => ($categoryId ? $categoryId : 'null')),
    'Admin.Advparameters.Notification'
);

}
$category->id_parent = $category->parent;
} elseif (isset($category->parent) && is_string($category->parent)) {
// Validation for parenting itself
if ($validateOnly && isset($category->name) && ($category->parent == $category->name)) {
$this->errors[] = $this->trans(
'A category can\'t be its own parent. You should rename it (current name: %1$s).',
$this->errors[] = $this->trans('A category can\'t be its own parent. You should rename it (current name: %1$s).',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about translation placeholder. Please use a variable name surrounded by %% an add it in the second parameter.

);
$this->errors[] = $this->trans('%1$s (ID: %2$s) cannot be saved', array(
$categoryToCreate->name[$idLang],
!empty($categoryToCreate->id) ? $categoryToCreate->id : 'null',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about translation placeholder. Please use a variable name surrounded by %% an add it in the second parameter.

if ($category->link_rewrite == '') {
$category->link_rewrite = 'friendly-url-autogeneration-failed';
$this->warnings[] = sprintf($this->trans('URL rewriting failed to auto-generate a friendly URL for: %s', array(), 'Admin.Advparameters.Notification'), $category->name[$default_language_id]);
$this->warnings[] = $this->trans('URL rewriting failed to auto-generate a friendly URL for: %s',
array($category->name[$defaultLanguageId]),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about translation placeholder. Please use a variable name surrounded by %% an add it in the second parameter.

$category_to_create->name[$default_language_id],
(isset($category_to_create->id) && !empty($category_to_create->id))? $category_to_create->id : 'null'
);
$this->errors[] = $this->trans('%1$s (ID: %2$s) cannot be saved', array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about translation placeholder. Please use a variable name surrounded by %% an add it in the second parameter.

if ($category['id_category']) {
$product->id_category[] = (int)$category['id_category'];
} else {
$this->errors[] = $this->trans(
'%s cannot be saved',
$this->errors[] = $this->trans('%s cannot be saved',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about translation placeholder. Please use a variable name surrounded by %% an add it in the second parameter.

'Invalid tag(s) (%s)',
$isTagAdded = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
if (!$isTagAdded) {
$this->addProductWarning(Tools::safeOutput($productData['name']), (int)$product->id, $this->trans('Invalid tag(s) (%s)',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about translation placeholder. Please use a variable name surrounded by %% an add it in the second parameter.

$image->delete();
$this->warnings[] = sprintf($this->trans('Error copying image: %s', array(), 'Admin.Advparameters.Notification'), $url);
$this->warnings[] = $this->trans('Error copying image: %s',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about translation placeholder. Please use a variable name surrounded by %% an add it in the second parameter.

@@ -2116,7 +2789,10 @@ protected function productImportOne($info, $default_language_id, $id_lang, $forc
}

if ($error) {
$this->warnings[] = sprintf($this->trans('Product #%1$d: the picture (%2$s) cannot be saved.', array(), 'Admin.Advparameters.Notification'), $image->id_product, $url);
$this->warnings[] = $this->trans('Product #%1$d: the picture (%2$s) cannot be saved.', array(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about translation placeholder. Please use a variable name surrounded by %% an add it in the second parameter.

'lastname' => array('label' => $this->trans('Last name', array(), 'Admin.Global').'*'),
'firstname' => array('label' => $this->trans('First name ', array(), 'Admin.Global').'*'),
'address1' => array('label' => $this->trans('Address', array(), 'Admin.Global').'*'),
'lastname' => array('label' => $this->trans('Last name', array(), 'Admin.Global') . '*'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it behave in RTL?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @maximebiloe could answer this ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as expected. I found several part of text which needs to be updated (in another PR).

!$regenerate
)) {
// TODO : insert translation placeholder here
$this->warnings[] = $manufacturer->image . ' ' . $this->trans('cannot be copied.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a variable here too

$imgWasCopied = AdminImportController::copyImg($store->id, null, $store->image, 'stores', !$regenerate);
if (!$imgWasCopied) {
$this->warnings[] = $store->image . ' '
. $this->trans('cannot be copied.', array(), 'Admin.Advparameters.Notification');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be a full sentence with a variable.

@AlexEven AlexEven removed the Waiting for wording Status: action required, waiting for wording label Sep 5, 2017
@LittleBigDev
Copy link
Contributor Author

Pushed fixes according to review comments.

@antoin-m
Copy link
Contributor

antoin-m commented Sep 5, 2017

image

@xBorderie
Copy link
Contributor

1vbiaa

@mickaelandrieu
Copy link
Contributor

Hello @LittleBigDev,

this need to be rebased (and probably validated again by @Quetzacoalt91 ?)

Mickaël

@PrestaShop PrestaShop deleted a comment from eternoendless Oct 19, 2017
@PrestaShop PrestaShop deleted a comment from LittleBigDev Oct 19, 2017
. $generatorsPageMessage
. '</a>';

$_FILES['file']['error'] = $uploadErrorMessage . $directiveExample;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ach, I didn't see this line. For the RTL languages, this will need to be merged in a single string to translate (in another PR).

/**
* Initializes import toolbar (for import display only)
*
* @return void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line to be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do

'lastname' => array('label' => $this->trans('Last name', array(), 'Admin.Global').'*'),
'firstname' => array('label' => $this->trans('First name ', array(), 'Admin.Global').'*'),
'address1' => array('label' => $this->trans('Address', array(), 'Admin.Global').'*'),
'lastname' => array('label' => $this->trans('Last name', array(), 'Admin.Global') . '*'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not as expected. I found several part of text which needs to be updated (in another PR).

// If nothing to fill, just get out ("0" string is NOT nothing).
if (empty($data) && $data !== '0') {
return true;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the first check was made before to handle the multilang case, and now this is an check which returns if the value is empty or equals 0.

Did you test that part? I'm afraid that would have some consequence on the feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I xDebugged it, and in any case, when data is empty, nothing is filled

Configuration::get('PS_HOME_CATEGORY'),
Configuration::get('PS_ROOT_CATEGORY')
);
$categoryId = !empty($info['id']) ? (int)$info['id'] : 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By looking at the next lines of this function, and the calls to new Category, I wonder if you should not set null if the $info['id'] is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree


if (!$shop_is_feature_active) {
if (!$shopIsFeatureActive) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's too much. ;)
But in that case, we have:

if ($shopIsFeatureActive) {
    [...]
    if (!$shopIsFeatureActive) {
    }
}

Which cannot happen.

Removing this test and the line after ($info['shop'] = 1;) is enough

$moreStep = 0
) {
if (!is_array($crossStepsVariables)) {
$crossStepsVariables = array();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm okay with the suggested change.

But I wonder if array &$crossStepsVariables = array(), would work as well and would fit better to our need.

) {
$categoryToCreate->link_rewrite = AdminImportController::createMultiLangField(
$categoryLinkRewrite
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it now in the test?

if ($taxRate < 0 || $taxRate > 100) {
$this->errors[] = $this->trans('Tax rate (%rate%) is not valid (at line %line%).', array(
'%rate%' => $taxRate,
'%line%' => $currentLine + 1,
$this->trans('Format: Between 0 and 100', array(), 'Admin.Advparameters.Notification')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In both case, it seems $this->trans('Format: Between 0 and 100', array(), 'Admin.Advparameters.Notification') is never displayed

@prestonBot prestonBot added the Waiting for wording Status: action required, waiting for wording label Oct 19, 2017
@LouiseBonnard LouiseBonnard removed the Waiting for wording Status: action required, waiting for wording label Oct 19, 2017
@LittleBigDev
Copy link
Contributor Author

LittleBigDev commented Oct 20, 2017

Hi @Quetzacoalt91 , I tried to address all your comments but after the rebase, I wasn't able to find the related code and/or to understand your suggestions. Could you please check it again ?

EDIT : and maybe we should use Reviewable for such a big review ?

@LittleBigDev LittleBigDev deleted the BOOM-294 branch November 7, 2017 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Waiting for QA Status: action required, waiting for test feedback
Projects
None yet
Development

Successfully merging this pull request may close these issues.