-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1ec4c2a
Showing
25 changed files
with
1,052 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
github: ghosterltd | ||
custom: ["https://www.paypal.me/thinghost"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
name: Bug report | ||
about: Technical issue with the Module | ||
|
||
--- | ||
|
||
### Preconditions (*) | ||
<!--- | ||
Provide the exact Magento version (example: 2.2.5) and any important information on the environment where bug is reproducible. | ||
--> | ||
1. | ||
2. | ||
|
||
### Steps to reproduce (*) | ||
<!--- | ||
Important: Provide a set of clear steps to reproduce this bug. We can not provide support without clear instructions on how to reproduce. | ||
--> | ||
1. | ||
2. | ||
|
||
### Expected result (*) | ||
<!--- Tell us what do you expect to happen. --> | ||
1. [Screenshots, logs or description] | ||
2. | ||
|
||
### Actual result (*) | ||
<!--- Tell us what happened instead. Include error messages and issues. --> | ||
1. [Screenshots, logs or description] | ||
2. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: ExtDN M2 Coding Standard | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
|
||
jobs: | ||
static: | ||
name: M2 Coding Standard | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: extdn/github-actions-m2/magento-coding-standard@master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
name: ExtDN M2 Integration Tests | ||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
mage247: | ||
name: Magento 2 Integration Tests (Magento v2.4.7) | ||
runs-on: ubuntu-latest | ||
services: | ||
mysql: | ||
image: mysql:8.0 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
ports: | ||
- 3306:3306 | ||
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
es: | ||
image: docker.io/wardenenv/elasticsearch:8.1 | ||
ports: | ||
- 9200:9200 | ||
env: | ||
'discovery.type': single-node | ||
'xpack.security.enabled': false | ||
ES_JAVA_OPTS: "-Xms64m -Xmx512m" | ||
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: M2 Integration Tests with Magento 2 | ||
uses: extdn/github-actions-m2/magento-integration-tests/8.3@master | ||
with: | ||
module_name: GhoSter_MultipleSalesRecipient | ||
composer_name: ghoster/module-multiplesalesrecipient | ||
ce_version: 2.4.7 | ||
|
||
mage246: | ||
name: Magento 2 Integration Tests (Magento v2.4.6) | ||
runs-on: ubuntu-latest | ||
services: | ||
mysql: | ||
image: mysql:8.0 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
ports: | ||
- 3306:3306 | ||
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
es: | ||
image: docker.io/wardenenv/elasticsearch:8.1 | ||
ports: | ||
- 9200:9200 | ||
env: | ||
'discovery.type': single-node | ||
'xpack.security.enabled': false | ||
ES_JAVA_OPTS: "-Xms64m -Xmx512m" | ||
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: M2 Integration Tests with Magento 2 | ||
uses: extdn/github-actions-m2/magento-integration-tests/8.2@master | ||
with: | ||
module_name: GhoSter_MultipleSalesRecipient | ||
composer_name: ghoster/module-multiplesalesrecipient | ||
ce_version: 2.4.6 | ||
|
||
mage244: | ||
name: Magento 2 Integration Tests (Magento v2.4.4) | ||
runs-on: ubuntu-latest | ||
services: | ||
mysql: | ||
image: mysql:8.0 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
ports: | ||
- 3306:3306 | ||
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
es: | ||
image: docker.io/wardenenv/elasticsearch:7.16 | ||
ports: | ||
- 9200:9200 | ||
env: | ||
'discovery.type': single-node | ||
'xpack.security.enabled': false | ||
ES_JAVA_OPTS: "-Xms64m -Xmx512m" | ||
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: M2 Integration Tests with Magento 2 | ||
uses: extdn/github-actions-m2/magento-integration-tests/7.4@master | ||
with: | ||
module_name: GhoSter_MultipleSalesRecipient | ||
composer_name: ghoster/module-multiplesalesrecipient | ||
ce_version: 2.4.4 | ||
|
||
mage24: | ||
name: Magento 2 Integration Tests (Magento v2.4.3) | ||
runs-on: ubuntu-latest | ||
services: | ||
mysql: | ||
image: mysql:8.0 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
ports: | ||
- 3306:3306 | ||
options: --tmpfs /tmp:rw --tmpfs /var/lib/mysql:rw --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
es: | ||
image: docker.io/wardenenv/elasticsearch:7.10 | ||
ports: | ||
- 9200:9200 | ||
env: | ||
'discovery.type': single-node | ||
'xpack.security.enabled': false | ||
ES_JAVA_OPTS: "-Xms64m -Xmx512m" | ||
options: --health-cmd="curl localhost:9200/_cluster/health?wait_for_status=yellow&timeout=60s" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: M2 Integration Tests with Magento 2 | ||
uses: extdn/github-actions-m2/magento-integration-tests/7.4@master | ||
with: | ||
module_name: GhoSter_MultipleSalesRecipient | ||
composer_name: ghoster/module-multiplesalesrecipient | ||
ce_version: 2.4.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.buildpath | ||
.project | ||
.settings/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
namespace GhoSter\MultipleSalesRecipient\Block\Form; | ||
|
||
use Magento\Customer\Api\AccountManagementInterface; | ||
use Magento\Customer\Api\CustomerRepositoryInterface; | ||
use Magento\Customer\Block\Form\Edit as CustomerFormEdit; | ||
use Magento\Customer\Model\Session; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Newsletter\Model\SubscriberFactory; | ||
use GhoSter\MultipleSalesRecipient\Model\Config; | ||
|
||
class Edit extends CustomerFormEdit | ||
{ | ||
/** | ||
* @var Config | ||
*/ | ||
protected $config; | ||
|
||
/** | ||
* Edit constructor. | ||
* @param Config $config | ||
* @param Context $context | ||
* @param Session $customerSession | ||
* @param SubscriberFactory $subscriberFactory | ||
* @param CustomerRepositoryInterface $customerRepository | ||
* @param AccountManagementInterface $customerAccountManagement | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Config $config, | ||
Context $context, | ||
Session $customerSession, | ||
SubscriberFactory $subscriberFactory, | ||
CustomerRepositoryInterface $customerRepository, | ||
AccountManagementInterface $customerAccountManagement, | ||
array $data = [] | ||
) { | ||
$this->config = $config; | ||
parent::__construct( | ||
$context, | ||
$customerSession, | ||
$subscriberFactory, | ||
$customerRepository, | ||
$customerAccountManagement, | ||
$data | ||
); | ||
} | ||
|
||
/** | ||
* Get additional sales emails | ||
* | ||
* @return array | ||
*/ | ||
public function getAdditionalSalesEmails(): array | ||
{ | ||
return array_map( | ||
'trim', | ||
explode( | ||
',', | ||
$this->getAdditionalSalesEmailsInput() | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Get additional sales emails input | ||
* | ||
* @return string | ||
*/ | ||
public function getAdditionalSalesEmailsInput(): string | ||
{ | ||
$customer = $this->getCustomer(); | ||
|
||
if ($customer->getId() && $customer->getCustomAttribute(Config::ATTRIBUTE_CODE)) { | ||
return $customer->getCustomAttribute(Config::ATTRIBUTE_CODE)->getValue(); | ||
} | ||
|
||
return ''; | ||
} | ||
|
||
/** | ||
* Main configuration | ||
* | ||
* @return Config | ||
*/ | ||
public function getConfig(): Config | ||
{ | ||
return $this->config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace GhoSter\MultipleSalesRecipient\Model; | ||
|
||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Store\Model\ScopeInterface; | ||
use Magento\Store\Model\Store; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
class Config | ||
{ | ||
public const ATTRIBUTE_CODE = 'multiple_sales_recipient'; | ||
public const XML_PATH_ENABLED_MODULE = 'multi_sales_emails/general/enabled'; | ||
public const XML_PATH_LIMIT_NUMBER = 'multi_sales_emails/general/limit_emails'; | ||
public const DEFAULT_LIMIT_NUMBER = 9999; | ||
/** | ||
* @var ScopeConfigInterface | ||
*/ | ||
protected $scopeConfig; | ||
|
||
/** @var StoreManagerInterface */ | ||
protected $storeManager; | ||
|
||
/** | ||
* Config constructor. | ||
* | ||
* @param ScopeConfigInterface $scopeConfig | ||
* @param StoreManagerInterface $storeManager | ||
*/ | ||
public function __construct( | ||
ScopeConfigInterface $scopeConfig, | ||
StoreManagerInterface $storeManager | ||
) { | ||
$this->scopeConfig = $scopeConfig; | ||
$this->storeManager = $storeManager; | ||
} | ||
|
||
/** | ||
* Check if module enabled | ||
* | ||
* @param null|string|bool|int|Store $store | ||
* @return bool | ||
*/ | ||
public function isEnabled($store = null): bool | ||
{ | ||
return $this->scopeConfig->isSetFlag( | ||
static::XML_PATH_ENABLED_MODULE, | ||
ScopeInterface::SCOPE_STORE, | ||
$store | ||
); | ||
} | ||
|
||
/** | ||
* Get Limit number or email | ||
* | ||
* @param null|string|bool|int|Store $store | ||
* @return int | ||
*/ | ||
public function getLimitEmailNumber($store = null): int | ||
{ | ||
$value = $this->scopeConfig->getValue( | ||
self::XML_PATH_LIMIT_NUMBER, | ||
ScopeInterface::SCOPE_STORE, | ||
$store | ||
); | ||
|
||
return empty($value) || $value == 0 | ||
? self::DEFAULT_LIMIT_NUMBER | ||
: (int)$value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace GhoSter\MultipleSalesRecipient\Model\ResourceModel; | ||
|
||
use Magento\Framework\Model\ResourceModel\Db\AbstractDb; | ||
use GhoSter\MultipleSalesRecipient\Model\Config; | ||
|
||
class UpdateAttribute extends AbstractDb | ||
{ | ||
/** | ||
* Resource initialization | ||
* | ||
* @return void | ||
*/ | ||
public function _construct()//phpcs:ignore Magento2.CodeAnalysis.EmptyBlock.DetectedFunction | ||
{ | ||
// TODO: Implement _construct() method. | ||
} | ||
|
||
/** | ||
* Save comment flag | ||
* | ||
* @param int $numberOfLimit | ||
* @return $this | ||
*/ | ||
public function saveCommentFlag(int $numberOfLimit): UpdateAttribute | ||
{ | ||
$connection = $this->getConnection(); | ||
|
||
$select = $connection->select()->from( | ||
$this->getTable('eav_attribute') | ||
)->where( | ||
'attribute_code = ?', | ||
Config::ATTRIBUTE_CODE | ||
); | ||
|
||
$row = $connection->fetchRow($select); | ||
|
||
if ($row) { | ||
$whereCondition = [ | ||
'attribute_id = ?' => $row['attribute_id'] | ||
]; | ||
|
||
$row['note'] = sprintf('Comma separated, limit at %s emails', $numberOfLimit); | ||
$connection->update($this->getTable('eav_attribute'), $row, $whereCondition); | ||
} | ||
|
||
return $this; | ||
} | ||
} |
Oops, something went wrong.