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

Send an email on low stock #8396

Merged
merged 17 commits into from Oct 18, 2017

Conversation

Projects
None yet
9 participants
@tomlev
Member

tomlev commented Oct 6, 2017

Questions Answers
Branch? 1.7.3
Description? Add checkbox to get notifications when a product is below the low-stock level, send mail on low-stock quantity update
Type? new feature
Category? BO
BC breaks? no
Deprecations? no
Fixed ticket? http://forge.prestashop.com/browse/FF-124
How to test? Go to BO product page > quantities (on a without-combinations product), check lowStockAlert checkbox, set not-null quantity on low stock threshold. Validate an order to get product quantity goes below the low stock level. All users with access on BO product page should receive the low-stock alert email. Same test must be ran on combination. Combinations low stock alerts can be edited by bulk actions.

Important guidelines


This change is Reviewable

@PrestaShop PrestaShop deleted a comment from codacy-bot Oct 6, 2017

@LittleBigDev

Nice PR !
Few code style changes are needed though.

Show outdated Hide outdated admin-dev/themes/new-theme/js/product-page/product-bulk-combinations.js Outdated
@@ -58,6 +58,9 @@ class CombinationCore extends ObjectModel
/** @var int|null Low stock for mail alert */
public $low_stock_threshold = null;
/** @var bool Low stock mail alert activated */
public $low_stock_alert = false;

This comment has been minimized.

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

When adding new variables, properties, methods, etc. please use the camelCase notation.

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

When adding new variables, properties, methods, etc. please use the camelCase notation.

@@ -79,6 +79,9 @@ class ProductCore extends ObjectModel
/** @var int|null Low stock for mail alert */
public $low_stock_threshold = null;
/** @var bool Low stock mail alert activated */
public $low_stock_alert = false;

This comment has been minimized.

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

When adding new variables, properties, methods, etc. please use the camelCase notation.

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

When adding new variables, properties, methods, etc. please use the camelCase notation.

@@ -1397,13 +1401,14 @@ public function addProductAttribute(
$upc,
$minimal_quantity,
$isbn,
$low_stock_threshold = null
$low_stock_threshold = null,
$low_stock_alert = false

This comment has been minimized.

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

When adding new variables, properties, methods, etc. please use the camelCase notation.

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

When adding new variables, properties, methods, etc. please use the camelCase notation.

Show outdated Hide outdated classes/Product.php Outdated
Show outdated Hide outdated install-dev/upgrade/upgrade.php Outdated
@@ -139,7 +142,8 @@ public function processProductAttribute($product, $combinationValues)
false,
array(),
$combinationValues['attribute_isbn'],
$combinationValues['attribute_low_stock_threshold']
$combinationValues['attribute_low_stock_threshold'],
$combinationValues['attribute_low_stock_alert']

This comment has been minimized.

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

Please add a trailing comma, even to the last array item

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

Please add a trailing comma, even to the last array item

This comment has been minimized.

@tomlev

tomlev Oct 6, 2017

Member

here is a function call ;)

@tomlev

tomlev Oct 6, 2017

Member

here is a function call ;)

This comment has been minimized.

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

ok -> 🚪

@LittleBigDev

LittleBigDev Oct 6, 2017

Contributor

ok -> 🚪

Show outdated Hide outdated src/Core/Stock/StockManager.php Outdated
Show outdated Hide outdated src/Core/Stock/StockManager.php Outdated
Show outdated Hide outdated src/Core/Stock/StockManager.php Outdated

@PrestaShop PrestaShop deleted a comment from codacy-bot Oct 6, 2017

@marionf

This comment has been minimized.

Show comment
Hide comment
@marionf

marionf Oct 9, 2017

Contributor

Hello @tomlev

I receive the email when the stock is = at the low stock level defined on product page.
I think I will have to receive the mail when it's < (and not =)

If I change something with the bulk action (low stock value or something else), it's not saved.
I have added a screenrecord on the forge ticket.

We have a little issue with the wording below:
capture du 2017-10-09 15-50-11
And I think it should be "all the users who have the right to run the stock page" instead of "this page".
I receive the email if I am allowed to see the stock page and not the product page.

Finally, maybe we can improve the display here:
capture du 2017-10-09 15-48-32
And here:
capture du 2017-10-09 16-24-04

Contributor

marionf commented Oct 9, 2017

Hello @tomlev

I receive the email when the stock is = at the low stock level defined on product page.
I think I will have to receive the mail when it's < (and not =)

If I change something with the bulk action (low stock value or something else), it's not saved.
I have added a screenrecord on the forge ticket.

We have a little issue with the wording below:
capture du 2017-10-09 15-50-11
And I think it should be "all the users who have the right to run the stock page" instead of "this page".
I receive the email if I am allowed to see the stock page and not the product page.

Finally, maybe we can improve the display here:
capture du 2017-10-09 15-48-32
And here:
capture du 2017-10-09 16-24-04

@PrestaShop PrestaShop deleted a comment from codacy-bot Oct 10, 2017

@emmanuelf75009

This comment has been minimized.

Show comment
Hide comment
@emmanuelf75009

emmanuelf75009 Oct 10, 2017

@marionf Sorry for the late comment. The user must received the email is the stock are = or < to the low-stock level.
Ok with the wording.

emmanuelf75009 commented Oct 10, 2017

@marionf Sorry for the late comment. The user must received the email is the stock are = or < to the low-stock level.
Ok with the wording.

@PrestaShop PrestaShop deleted a comment from codacy-bot Oct 11, 2017

@PrestaShop PrestaShop deleted a comment from codacy-bot Oct 12, 2017

@marionf marionf added QA ✔️ and removed waiting for QA labels Oct 12, 2017

@eternoendless

This comment has been minimized.

Show comment
Hide comment
@eternoendless

eternoendless Oct 13, 2017

Member

:lgtm:


Reviewed 10 of 27 files at r1, 2 of 3 files at r2, 5 of 5 files at r5, 2 of 5 files at r6, 8 of 8 files at r7, 5 of 5 files at r8, 1 of 1 files at r9.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

Member

eternoendless commented Oct 13, 2017

:lgtm:


Reviewed 10 of 27 files at r1, 2 of 3 files at r2, 5 of 5 files at r5, 2 of 5 files at r6, 8 of 8 files at r7, 5 of 5 files at r8, 1 of 1 files at r9.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@eternoendless

This comment has been minimized.

Show comment
Hide comment
@eternoendless

eternoendless Oct 13, 2017

Member

Reviewed 1 of 1 files at r10.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

Member

eternoendless commented Oct 13, 2017

Reviewed 1 of 1 files at r10.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from Reviewable

@codacy-bot

This comment has been minimized.

Show comment
Hide comment
@codacy-bot

codacy-bot Oct 13, 2017

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- src/Core/Stock/StockManager.php  15
- src/Adapter/Product/AdminProductWrapper.php  1
         

See the complete overview on Codacy

codacy-bot commented Oct 13, 2017

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- src/Core/Stock/StockManager.php  15
- src/Adapter/Product/AdminProductWrapper.php  1
         

See the complete overview on Codacy

@PrestaShop PrestaShop deleted a comment from codacy-bot Oct 13, 2017

@maximebiloe

This comment has been minimized.

Show comment
Hide comment
@maximebiloe

maximebiloe Oct 13, 2017

Contributor

⚠️ Be careful, you're adding a new e-mail template. Don't forget to add it here: https://github.com/PrestaShop/ps_emailgenerator/
Otherwise, it won't be translated (ping @eternoendless)

Contributor

maximebiloe commented Oct 13, 2017

⚠️ Be careful, you're adding a new e-mail template. Don't forget to add it here: https://github.com/PrestaShop/ps_emailgenerator/
Otherwise, it won't be translated (ping @eternoendless)

@xBorderie

This comment has been minimized.

Show comment
Hide comment
@xBorderie

xBorderie Oct 16, 2017

Contributor

Thanks for the heads-up, Maxime!
I'll ping @LouiseBonnard too, who is charge of Content.

Contributor

xBorderie commented Oct 16, 2017

Thanks for the heads-up, Maxime!
I'll ping @LouiseBonnard too, who is charge of Content.

@eternoendless

This comment has been minimized.

Show comment
Hide comment
@eternoendless
Member

eternoendless commented Oct 18, 2017

@eternoendless

This comment has been minimized.

Show comment
Hide comment
@eternoendless
Member

eternoendless commented Oct 18, 2017

Thank you @tomlev

@eternoendless eternoendless merged commit fa48a13 into PrestaShop:develop Oct 18, 2017

3 checks passed

codacy/pr Good work! A positive pull request.
Details
code-review/reviewable 30 files reviewed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@maximebiloe

This comment has been minimized.

Show comment
Hide comment
@maximebiloe

maximebiloe Oct 18, 2017

Contributor

It exists for the ps_emailalerts module, not as a core email. You need to move it (into the module), otherwise it won't be found and at best, it will send the english mail, at worst, it will throw a 500 💣

Contributor

maximebiloe commented Oct 18, 2017

It exists for the ps_emailalerts module, not as a core email. You need to move it (into the module), otherwise it won't be found and at best, it will send the english mail, at worst, it will throw a 500 💣

@eternoendless

This comment has been minimized.

Show comment
Hide comment
@eternoendless

eternoendless Oct 18, 2017

Member

Oh you mean it needs to go into templates/core/ on the module!
@tomlev can you see to it please?

Member

eternoendless commented Oct 18, 2017

Oh you mean it needs to go into templates/core/ on the module!
@tomlev can you see to it please?

@maximebiloe

This comment has been minimized.

Show comment
Hide comment
@maximebiloe

maximebiloe Oct 19, 2017

Contributor

Yes 😄
You can add to the roadmap a task to "templatize" the mails :trollface:

Contributor

maximebiloe commented Oct 19, 2017

Yes 😄
You can add to the roadmap a task to "templatize" the mails :trollface:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment