Skip to content

Commit

Permalink
Merge pull request #135 from PrestaShop/dev
Browse files Browse the repository at this point in the history
Release 2.4.2
  • Loading branch information
leemyongpakvn authored Sep 2, 2023
2 parents 3145d0c + 7e00934 commit fa60110
Show file tree
Hide file tree
Showing 39 changed files with 361 additions and 603 deletions.
61 changes: 3 additions & 58 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,61 +2,6 @@ name: Build
on: [push, pull_request]

jobs:
deploy:
name: build dependencies & create artifact
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Install composer dependencies
run: composer install --no-dev -o
- name: Clean-up project
uses: PrestaShopCorp/[email protected]
- name: Prepare auto-index tool
run: |
composer global require prestashop/autoindex
- name: Generate index.php
run: |
~/.composer/vendor/bin/autoindex
- name: Create & upload artifact
uses: actions/upload-artifact@v1
with:
name: ${{ github.event.repository.name }}
path: ../
update_release_draft:
runs-on: ubuntu-latest
needs: [deploy]
if: github.event_name == 'push' && github.event.ref == 'refs/heads/master'
steps:
- name: Download artifact
uses: actions/download-artifact@v1
with:
name: ${{ github.event.repository.name }}
- id: release_info
uses: toolmantim/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare for Release
run: |
cd ${{ github.event.repository.name }}
zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }}
- name: Clean existing assets
shell: bash
run: |
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
assets=`bin/hub api -t repos/${{ github.repository }}/releases/${{ steps.release_info.outputs.id }}/assets | awk '/\].url/ { print $2 }'`
for asset in $assets
do
bin/hub api -X DELETE $asset
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to GitHub Release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.release_info.outputs.upload_url }}
asset_path: ./${{ github.event.repository.name }}/${{ github.event.repository.name }}.zip
asset_name: ${{ github.event.repository.name }}.zip
asset_content_type: application/zip
build-and-release-draft:
name: Build & Release draft
uses: PrestaShop/.github/.github/workflows/build-release.yml@master
39 changes: 19 additions & 20 deletions MailAlert.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
<?php
/**
* 2007-2020 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2020 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
class MailAlert extends ObjectModel
{
Expand Down Expand Up @@ -170,16 +164,16 @@ public static function getMailAlerts($id_customer, $id_lang, Shop $shop = null)
public static function sendCustomerAlert($id_product, $id_product_attribute)
{
$link = new Link();
$context = Context::getContext()->cloneContext();
$context = Context::getContext();
$id_product = (int) $id_product;
$id_product_attribute = (int) $id_product_attribute;
$customers = self::getCustomers($id_product, $id_product_attribute);
$current_shop = $context->shop->id;
$customers = self::getCustomers($id_product, $id_product_attribute, $current_shop);

foreach ($customers as $customer) {
$id_shop = (int) $customer['id_shop'];
$id_lang = (int) $customer['id_lang'];
$context->shop->id = $id_shop;
$context->language->id = $id_lang;

$product = new Product($id_product, false, $id_lang, $id_shop);
$product_name = Product::getProductName($product->id, $id_product_attribute, $id_lang);
Expand Down Expand Up @@ -255,6 +249,7 @@ public static function sendCustomerAlert($id_product, $id_product_attribute)
$id_shop
);
}
$context->shop->id = $current_shop;
}

/*
Expand Down Expand Up @@ -306,13 +301,17 @@ public static function getProductAttributeCombination($id_product_attribute, $id

/*
* Get customers waiting for alert on the specified product/product attribute
* in shop `$id_shop` and if the shop group shares the stock in all shops of the shop group
*/
public static function getCustomers($id_product, $id_product_attribute)
public static function getCustomers($id_product, $id_product_attribute, $id_shop)
{
$sql = '
SELECT id_customer, customer_email, id_shop, id_lang
FROM `' . _DB_PREFIX_ . self::$definition['table'] . '`
WHERE `id_product` = ' . (int) $id_product . ' AND `id_product_attribute` = ' . (int) $id_product_attribute;
SELECT mc.id_customer, mc.customer_email, mc.id_shop, mc.id_lang
FROM `' . _DB_PREFIX_ . self::$definition['table'] . '` mc
INNER JOIN `' . _DB_PREFIX_ . 'shop` s on s.id_shop = mc.id_shop
INNER JOIN `' . _DB_PREFIX_ . 'shop_group` sg on s.id_shop_group = sg.id_shop_group and (s.id_shop = ' . (int) $id_shop . ' or sg.share_stock = 1)
INNER JOIN `' . _DB_PREFIX_ . 'shop` s2 on s2.id_shop = mc.id_shop and s2.id_shop = ' . (int) $id_shop . '
WHERE mc.`id_product` = ' . (int) $id_product . ' AND mc.`id_product_attribute` = ' . (int) $id_product_attribute;

return Db::getInstance((bool) _PS_USE_SQL_SLAVE_)->executeS($sql);
}
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@

Make your everyday life easier, handle mail alerts about stock and orders, addressed to you as well as your customers.

## Compatibility

PrestaShop: `1.7.6.0` or later

## Multistore compatibility

This module is partially compatible with the multistore feature. Some of its options might not be available.

## How to test

Link to specs : https://docs.prestashop-project.org/functional-documentation/functional-documentation/ux-ui/back-office/improve/modules/configure-mail-alerts-ps_mailalerts

Configure Customer notifications and Merchant notifications
Add stock to product, edit an order, place an order, remove stock from product, set threshold for a product. 
Check that the emails are well sent

## Reporting issues

You can report issues with this module in the main PrestaShop repository. [Click here to report an issue][report-issue].
Expand Down
49 changes: 25 additions & 24 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{
"name": "prestashop/ps_emailalerts",
"description": "PrestaShop module ps_emailalerts",
"homepage": "https://github.com/PrestaShop/ps_emailalerts",
"license": "AFL-3.0",
"authors": [
{
"name": "PrestaShop SA",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.6"
},
"require-dev": {
"prestashop/php-dev-tools": "^3.16"
},
"config": {
"platform": {
"php": "5.6.0"
"name": "prestashop/ps_emailalerts",
"description": "PrestaShop module ps_emailalerts",
"homepage": "https://github.com/PrestaShop/ps_emailalerts",
"license": "AFL-3.0",
"authors": [
{
"name": "PrestaShop SA",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.6"
},
"preferred-install": "dist",
"prepend-autoloader": false
},
"type": "prestashop-module"
}
"require-dev": {
"prestashop/php-dev-tools": "^3.16"
},
"config": {
"platform": {
"php": "5.6.0"
},
"preferred-install": "dist",
"prepend-autoloader": false
},
"type": "prestashop-module",
"author": "PrestaShop"
}
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<module>
<name>ps_emailalerts</name>
<displayName><![CDATA[Mail alerts]]></displayName>
<version><![CDATA[2.4.1]]></version>
<version><![CDATA[2.4.2]]></version>
<description><![CDATA[Sends e-mail notifications to customers and merchants regarding stock and order modifications.]]></description>
<author><![CDATA[PrestaShop]]></author>
<tab><![CDATA[administration]]></tab>
Expand Down
20 changes: 7 additions & 13 deletions controllers/front/account.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
<?php
/**
* 2007-2020 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2020 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

/**
Expand Down
22 changes: 8 additions & 14 deletions controllers/front/actions.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
<?php
/**
* 2007-2020 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2020 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/

/**
Expand Down Expand Up @@ -95,7 +89,7 @@ public function processAdd()
} elseif (Validate::isEmail((string) Tools::getValue('customer_email'))) {
$customer_email = (string) Tools::getValue('customer_email');
$customer = $context->customer->getByEmail($customer_email);
$id_customer = (isset($customer->id) && ($customer->id != null)) ? (int) $customer->id : null;
$id_customer = (isset($customer->id) && ($customer->id != null)) ? (int) $customer->id : 0;
} else {
exit(json_encode(
[
Expand Down
20 changes: 7 additions & 13 deletions controllers/front/index.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
<?php
/**
* 2007-2020 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2020 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
Expand Down
20 changes: 7 additions & 13 deletions controllers/index.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
<?php
/**
* 2007-2020 PrestaShop.
* Copyright since 2007 PrestaShop SA and Contributors
* PrestaShop is an International Registered Trademark & Property of PrestaShop SA
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License 3.0 (AFL-3.0)
* that is bundled with this package in the file LICENSE.txt.
* This source file is subject to the Academic Free License version 3.0
* that is bundled with this package in the file LICENSE.md.
* It is also available through the world-wide-web at this URL:
* https://opensource.org/licenses/AFL-3.0
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <[email protected]>
* @copyright 2007-2020 PrestaShop SA
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
* International Registered Trademark & Property of PrestaShop SA
* @author PrestaShop SA and Contributors <[email protected]>
* @copyright Since 2007 PrestaShop SA and Contributors
* @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
Expand Down
Loading

0 comments on commit fa60110

Please sign in to comment.