-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] #23 Add 'is visible on checkout' option to backend attribut…
…e mgmt
- Loading branch information
Showing
3 changed files
with
110 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,58 @@ | ||
<?php | ||
/** | ||
* Copyright © 2015 FireGento e.V. - All rights reserved. | ||
* See LICENSE.md bundled with this module for license details. | ||
*/ | ||
namespace FireGento\MageSetup\Observer; | ||
|
||
use Magento\Framework\Event\ObserverInterface; | ||
use Magento\Config\Model\Config\Source\Yesno; | ||
|
||
/** | ||
* Class AddProductAttributeVisibleCheckoutObserver | ||
* | ||
* @package FireGento\MageSetup\Observer | ||
*/ | ||
class AddProductAttributeVisibleCheckoutObserver implements ObserverInterface | ||
{ | ||
/** | ||
* @var Yesno | ||
*/ | ||
private $yesNo; | ||
|
||
/** | ||
* AddProductAttributeVisibleCheckoutObserver constructor. | ||
* | ||
* @param Yesno $yesNo | ||
*/ | ||
public function __construct(Yesno $yesNo) | ||
{ | ||
$this->yesNo = $yesNo; | ||
} | ||
|
||
/** | ||
* lala | ||
* | ||
* @param \Magento\Framework\Event\Observer $observer | ||
* @return void | ||
*/ | ||
public function execute(\Magento\Framework\Event\Observer $observer) | ||
{ | ||
/** @var \Magento\Framework\Data\Form $form */ | ||
$form = $observer->getEvent()->getData('form'); | ||
|
||
/** @var \Magento\Framework\Data\Form\Element\Fieldset $fieldset */ | ||
$fieldset = $form->getElement('front_fieldset'); | ||
|
||
$fieldset->addField( | ||
'is_visible_on_checkout', | ||
'select', | ||
[ | ||
'name' => 'is_visible_on_checkout', | ||
'label' => __('Visible in Checkout'), | ||
'title' => __('Visible in Checkout'), | ||
'values' => $this->yesNo->toOptionArray(), | ||
] | ||
); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace FireGento\MageSetup\Setup; | ||
|
||
use Magento\Framework\Setup\InstallSchemaInterface; | ||
use Magento\Framework\Setup\SchemaSetupInterface; | ||
use Magento\Framework\Setup\ModuleContextInterface; | ||
|
||
/** | ||
* Class InstallSchema | ||
* | ||
* @package FireGento\MageSetup\Setup | ||
* @codeCoverageIgnore | ||
*/ | ||
class InstallSchema implements InstallSchemaInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) | ||
*/ | ||
public function install(SchemaSetupInterface $setup, ModuleContextInterface $context) | ||
{ | ||
$installer = $setup; | ||
$installer->startSetup(); | ||
|
||
$installer->getConnection()->addColumn( | ||
$installer->getTable('catalog_eav_attribute'), | ||
'is_visible_on_checkout', | ||
[ | ||
'type' => \Magento\Framework\DB\Ddl\Table::TYPE_SMALLINT, | ||
'unsigned' => true, | ||
'nullable' => false, | ||
'default' => '0', | ||
'comment' => 'Is Visible On Checkout' | ||
] | ||
); | ||
|
||
$installer->endSetup(); | ||
} | ||
} |
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,12 @@ | ||
<?xml version="1.0"?> | ||
<!-- | ||
/** | ||
* Copyright © 2015 FireGento e.V. - All rights reserved. | ||
* See LICENSE.md bundled with this module for license details. | ||
*/ | ||
--> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> | ||
<event name="adminhtml_catalog_product_attribute_edit_frontend_prepare_form"> | ||
<observer name="product_attribute_form" instance="FireGento\MageSetup\Observer\AddProductAttributeVisibleCheckoutObserver" /> | ||
</event> | ||
</config> |