-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
Showing
22 changed files
with
352 additions
and
37 deletions.
There are no files selected for viewing
Empty file.
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,39 @@ | ||
|
||
|
||
<!--- Before adding a new issue, please check all closed and existing issues to make sure this is not a duplicate --> | ||
|
||
|
||
<!--- https://www.magepal.com/ for fast Premium Support --> | ||
|
||
|
||
#### Magento version #: | ||
|
||
#### Edition (EE, CE, OS, etc): | ||
|
||
#### Expected behavior: | ||
|
||
#### Actual behavior: | ||
|
||
#### Steps to reproduce: | ||
|
||
#### Preconditions | ||
<!--- Provide a more detailed information of environment you use --> | ||
<!--- Magento version, tag, HEAD, etc., PHP & MySQL version, etc.. --> | ||
|
||
|
||
<!--- | ||
PLEASE NOTE: | ||
We receive multiple emails & support tickets almost daily asking for help. | ||
In most cases these issues have nothing to do with our extension and mostly | ||
caused by lack of basic Magento knowledge or not following installation instructions. | ||
At MagePal, our goal is to develop a wide variety of both free and paid extension | ||
and due to our limited resources, our main focus are fixing reported bugs and developing | ||
other great extensions. | ||
Because of this, we cannot provide free support for our free extensions. | ||
However, we do offer very affordable support options and/or training. | ||
For more information visit www.magepal.com or email us at support@magepal.com. | ||
--> |
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,11 @@ | ||
name: PHPCS | ||
on: [push] | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: PHPCS | ||
run: docker run --rm -v $PWD:/code:ro domw/phpcs phpcs --colors --standard=Magento2 --report=full,summary,gitblame --extensions=php,phtml ./ | ||
- name: compatibility | ||
run: docker run --rm -v $PWD:/code:ro domw/phpcompatibility phpcs --standard=PHPCompatibility --runtime-set testVersion 5.6-7.3 --colors --warning-severity=0 --report=full,summary --extensions=php,phtml ./ |
123 changes: 123 additions & 0 deletions
123
Block/Adminhtml/System/Config/Form/Composer/Version.php
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,123 @@ | ||
<?php | ||
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | support@magepal.com | ||
*/ | ||
|
||
namespace MagePal\LinkProduct\Block\Adminhtml\System\Config\Form\Composer; | ||
|
||
use Exception; | ||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\App\DeploymentConfig; | ||
use Magento\Framework\Component\ComponentRegistrar; | ||
use Magento\Framework\Component\ComponentRegistrarInterface; | ||
use Magento\Framework\Data\Form\Element\AbstractElement as AbstractElementAlias; | ||
use Magento\Framework\Filesystem\Directory\ReadFactory; | ||
use Magento\Framework\Phrase; | ||
|
||
/** | ||
* Admin block class for composer version | ||
*/ | ||
class Version extends Field | ||
{ | ||
|
||
/** | ||
* @var DeploymentConfig | ||
*/ | ||
protected $deploymentConfig; | ||
|
||
/** | ||
* @var ComponentRegistrarInterface | ||
*/ | ||
protected $componentRegistrar; | ||
|
||
/** | ||
* @var ReadFactory | ||
*/ | ||
protected $readFactory; | ||
|
||
/** | ||
* @param Context $context | ||
* @param DeploymentConfig $deploymentConfig | ||
* @param ComponentRegistrarInterface $componentRegistrar | ||
* @param ReadFactory $readFactory | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
DeploymentConfig $deploymentConfig, | ||
ComponentRegistrarInterface $componentRegistrar, | ||
ReadFactory $readFactory, | ||
array $data = [] | ||
) { | ||
$this->deploymentConfig = $deploymentConfig; | ||
$this->componentRegistrar = $componentRegistrar; | ||
$this->readFactory = $readFactory; | ||
parent::__construct($context, $data); | ||
} | ||
|
||
/** | ||
* Render button | ||
* | ||
* @param AbstractElementAlias $element | ||
* @return string | ||
*/ | ||
public function render(AbstractElementAlias $element) | ||
{ | ||
// Remove scope label | ||
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); | ||
return parent::render($element); | ||
} | ||
|
||
/** | ||
* Return element html | ||
* | ||
* @param AbstractElementAlias $element | ||
* @return string | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
protected function _getElementHtml(AbstractElementAlias $element) | ||
{ | ||
return 'v' . $this->getVersion(); | ||
} | ||
|
||
/** | ||
* Get Module version number | ||
* | ||
* @return string | ||
*/ | ||
public function getVersion() | ||
{ | ||
return $this->getComposerVersion($this->getModuleName()); | ||
} | ||
|
||
/** | ||
* Get module composer version | ||
* | ||
* @param $moduleName | ||
* @return Phrase|string|void | ||
*/ | ||
public function getComposerVersion($moduleName) | ||
{ | ||
$path = $this->componentRegistrar->getPath( | ||
ComponentRegistrar::MODULE, | ||
$moduleName | ||
); | ||
|
||
try { | ||
$directoryRead = $this->readFactory->create($path); | ||
$composerJsonData = $directoryRead->readFile('composer.json'); | ||
if ($composerJsonData) { | ||
$data = json_decode($composerJsonData); | ||
if (!empty($data->version)) { | ||
return $data->version; | ||
} | ||
} | ||
return __('Unknown'); | ||
} catch (Exception $e) { | ||
return __('Unknown'); | ||
} | ||
} | ||
} |
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,75 @@ | ||
<?php | ||
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | support@magepal.com | ||
*/ | ||
|
||
namespace MagePal\LinkProduct\Block\Adminhtml\System\Config\Form\Module; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\Module\ModuleListInterface; | ||
|
||
/** | ||
* Admin block class for module version | ||
*/ | ||
class Version extends Field | ||
{ | ||
|
||
/** | ||
* @var ModuleListInterface | ||
*/ | ||
protected $_moduleList; | ||
|
||
/** | ||
* @param Context $context | ||
* @param ModuleListInterface $moduleList | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
ModuleListInterface $moduleList, | ||
array $data = [] | ||
) { | ||
parent::__construct($context, $data); | ||
$this->_moduleList = $moduleList; | ||
} | ||
|
||
/** | ||
* Render button | ||
* | ||
* @param AbstractElement $element | ||
* @return string | ||
*/ | ||
public function render(AbstractElement $element) | ||
{ | ||
// Remove scope label | ||
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); | ||
return parent::render($element); | ||
} | ||
|
||
/** | ||
* Return element html | ||
* | ||
* @param AbstractElement $element | ||
* @return string | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
protected function _getElementHtml(AbstractElement $element) | ||
{ | ||
return 'v' . $this->getVersion(); | ||
} | ||
|
||
/** | ||
* Get Module version number | ||
* | ||
* @return string | ||
*/ | ||
public function getVersion() | ||
{ | ||
$moduleInfo = $this->_moduleList->getOne($this->getModuleName()); | ||
return $moduleInfo['setup_version']; | ||
} | ||
} |
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
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
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
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
14 changes: 8 additions & 6 deletions
14
Plugin/CatalogImportExport/Model/Import/Product.php
100644 → 100755
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 |
---|---|---|
@@ -1,26 +1,28 @@ | ||
<?php | ||
/** | ||
* Copyright © MagePal LLC. All rights reserved. | ||
* See COPYING.txt for license details. | ||
* http://www.magepal.com | support@magepal.com | ||
*/ | ||
|
||
namespace MagePal\LinkProduct\Plugin\CatalogImportExport\Model\Import; | ||
|
||
use Magento\CatalogImportExport\Model\Import\Product as ProductImportExport; | ||
use MagePal\LinkProduct\Model\Product\Link; | ||
|
||
/** | ||
* @see Product::getLinkNameToId | ||
*/ | ||
class Product | ||
{ | ||
/** | ||
* REMARK: needs core patch | ||
* https://github.com/magento/magento2/pull/21230/commits/0846e9aed7040659e7ce3e109eb91df3f5fdfb7e.patch | ||
* | ||
* @param Product $subject | ||
* @param ProductImportExport $subject | ||
* @param $result | ||
* @return mixed | ||
*/ | ||
public function afterGetLinkNameToId(\Magento\CatalogImportExport\Model\Import\Product $subject, $result) | ||
public function afterGetLinkNameToId(ProductImportExport $subject, $result) | ||
{ | ||
$result['_accessory_'] = Link::LINK_TYPE_ACCESSORY; | ||
return $result; | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.