From 48f4f0de0934c4c510236dc909cd492ba660e959 Mon Sep 17 00:00:00 2001 From: Alex Dong Date: Thu, 5 Jan 2023 17:38:25 +0700 Subject: [PATCH] Format --- Api/Data/SizechartInterface.php | 2 +- Block/Adminhtml/Sizechart/AddRow.php | 31 ++-- Block/Adminhtml/Sizechart/Edit/Form.php | 20 ++- .../Sizechart/Edit/Tab/Condition.php | 8 +- Block/Adminhtml/Sizechart/Edit/Tab/Main.php | 22 +-- Block/Adminhtml/Sizechart/Edit/Tabs.php | 6 +- Block/Product/Sizechart.php | 19 +- Controller/Adminhtml/Action.php | 24 ++- Controller/Adminhtml/Sizechart/AddRow.php | 2 +- Controller/Adminhtml/Sizechart/Index.php | 6 +- Controller/Adminhtml/Sizechart/MassDelete.php | 9 +- Controller/Adminhtml/Sizechart/Save.php | 5 +- Controller/Index/Index.php | 13 +- Cron/Cron.php | 3 +- Helper/Cache.php | 3 +- Helper/Data.php | 26 ++- Model/Cron.php | 12 +- Model/ResourceModel/Sizechart.php | 8 +- Model/ResourceModel/Sizechart/Collection.php | 10 +- Model/Sizechart.php | 167 +++++++++++------- Model/Status.php | 14 +- Model/TypeDisplay.php | 16 +- Serialize/Serializer/Json.php | 30 ++-- Setup/InstallSchema.php | 161 +++++++++-------- Setup/UpgradeSchema.php | 33 ++-- etc/acl.xml | 4 +- etc/adminhtml/menu.xml | 7 +- etc/di.xml | 5 +- etc/module.xml | 2 +- 29 files changed, 355 insertions(+), 313 deletions(-) diff --git a/Api/Data/SizechartInterface.php b/Api/Data/SizechartInterface.php index f805918..bd97f7e 100644 --- a/Api/Data/SizechartInterface.php +++ b/Api/Data/SizechartInterface.php @@ -36,7 +36,7 @@ public function getCreatedAt(); public function setCreatedAt($createdAt); public function getTemplateCss(); public function setTemplateCss($templateCss); - public function getConditions(); + public function getConditions(); public function setConditions($conditions); public function getStoreView(); public function setStoreView($stores); diff --git a/Block/Adminhtml/Sizechart/AddRow.php b/Block/Adminhtml/Sizechart/AddRow.php index 5679e95..d4d1bb2 100644 --- a/Block/Adminhtml/Sizechart/AddRow.php +++ b/Block/Adminhtml/Sizechart/AddRow.php @@ -10,8 +10,7 @@ public function __construct( \Magento\Backend\Block\Widget\Context $context, \Magento\Framework\Registry $registry, array $data = [] - ) - { + ) { $this->_coreRegistry = $registry; parent::__construct($context, $data); } @@ -25,28 +24,26 @@ protected function _construct() if ($this->_isAllowedAction('Magepow_Sizechart::add_row')) { $this->buttonList->update('save', 'label', __('Save')); $this->buttonList->add( - 'saveandcontinue', - [ - 'label' => __('Save and Continue Edit'), - 'class' => 'save', - 'data_attribute' => [ - 'mage-init' => [ - 'button' => [ - 'event' => 'saveAndContinueEdit', - 'target' => '#edit_form' + 'saveandcontinue', + [ + 'label' => __('Save and Continue Edit'), + 'class' => 'save', + 'data_attribute' => [ + 'mage-init' => [ + 'button' => [ + 'event' => 'saveAndContinueEdit', + 'target' => '#edit_form' + ] ] ] ] - ] - ); - + ); } else { $this->buttonList->remove('save'); } // $this->buttonList->remove('reset'); - - } + } public function getHeaderText() { @@ -64,4 +61,4 @@ public function getFormActionUrl() return $this->getUrl('*/*/save'); } -} +} \ No newline at end of file diff --git a/Block/Adminhtml/Sizechart/Edit/Form.php b/Block/Adminhtml/Sizechart/Edit/Form.php index 8ce87fd..446493b 100644 --- a/Block/Adminhtml/Sizechart/Edit/Form.php +++ b/Block/Adminhtml/Sizechart/Edit/Form.php @@ -1,9 +1,10 @@ _localeDate->getDateFormat(\IntlDateFormatter::SHORT); $model = $this->_coreRegistry->registry('row_data'); $form = $this->_formFactory->create( - ['data' => [ - 'id' => 'edit_form', - 'enctype' => 'multipart/form-data', - 'action' => $this->getData('action'), - 'method' => 'post' - ] + [ + 'data' => [ + 'id' => 'edit_form', + 'enctype' => 'multipart/form-data', + 'action' => $this->getData('action'), + 'method' => 'post' + ] ] ); $form->setValues($model->getData()); $form->setUseContainer(true); $this->setForm($form); - + return parent::_prepareForm(); } } \ No newline at end of file diff --git a/Block/Adminhtml/Sizechart/Edit/Tab/Condition.php b/Block/Adminhtml/Sizechart/Edit/Tab/Condition.php index 1d58be3..196dda3 100644 --- a/Block/Adminhtml/Sizechart/Edit/Tab/Condition.php +++ b/Block/Adminhtml/Sizechart/Edit/Tab/Condition.php @@ -22,7 +22,7 @@ public function __construct( \Magento\Backend\Block\Widget\Form\Renderer\Fieldset $rendererFieldset, array $data = [] ) { - + $this->_conditions = $conditions; $this->_ruleFactory = $ruleFactory; $this->_renderFieldSet = $rendererFieldset; @@ -34,14 +34,14 @@ protected function _prepareForm() $model = $this->_coreRegistry->registry('row_data'); $form = $this->_formFactory->create(); $form->setHtmlIdPrefix('wkgrid_'); - + $fieldsetId = 'conditions_fieldset'; $formName = 'catalog_rule_form'; $widgetParameters = $model->getParameters(); $modelConditions = $this->_ruleFactory->create(); - if (is_array($widgetParameters)){ + if (is_array($widgetParameters)) { $modelConditions->loadPost($widgetParameters); $modelConditions->getConditions()->setJsFormObject($fieldsetId); } @@ -76,7 +76,6 @@ protected function _prepareForm() $this->setForm($form); return parent::_prepareForm(); - } public function getTabLabel() @@ -84,7 +83,6 @@ public function getTabLabel() return __('Condition apply for products'); } - public function getTabTitle() { return __('Condition apply for products'); diff --git a/Block/Adminhtml/Sizechart/Edit/Tab/Main.php b/Block/Adminhtml/Sizechart/Edit/Tab/Main.php index c05f646..f52aa74 100644 --- a/Block/Adminhtml/Sizechart/Edit/Tab/Main.php +++ b/Block/Adminhtml/Sizechart/Edit/Tab/Main.php @@ -7,14 +7,12 @@ class Main extends Generic implements TabInterface { - - protected $_systemStore; protected $_objectManager; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Framework\Registry $registry, - \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, + \Magento\Cms\Model\Wysiwyg\Config $wysiwygConfig, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\ObjectManagerInterface $objectManager, \Magepow\Sizechart\Model\Status $options, @@ -52,8 +50,8 @@ protected function _prepareForm() ['legend' => __('Add Size Chart Rule'), 'class' => 'fieldset-wide'] ); } - - $fieldset->addField( + + $fieldset->addField( 'name', 'text', [ @@ -61,7 +59,7 @@ protected function _prepareForm() 'label' => __('Name'), 'id' => 'name', 'title' => __('Name'), - 'class'=>'required_entry', + 'class' => 'required_entry', 'required' => true, ] ); @@ -90,7 +88,7 @@ protected function _prepareForm() ); $model->setStoreId($this->_storeManager->getStore(true)->getId()); } - + $fieldset->addField( 'description', 'textarea', @@ -99,13 +97,13 @@ protected function _prepareForm() 'label' => __('Description'), 'id' => 'description', 'title' => __('Description'), - 'style'=>'height:10em', + 'style' => 'height:10em', 'required' => false, ] ); - + $wysiwygConfig = $this->_wysiwygConfig->getConfig(['tab_id' => $this->getTabId()]); - $fieldset->addField( + $fieldset->addField( 'sizechart_info', 'editor', [ @@ -140,7 +138,7 @@ protected function _prepareForm() 'required' => true, ] ); - + $fieldset->addField( 'is_active', 'select', @@ -159,7 +157,6 @@ protected function _prepareForm() $this->setForm($form); return parent::_prepareForm(); - } public function getTabLabel() @@ -167,7 +164,6 @@ public function getTabLabel() return __('General Information'); } - public function getTabTitle() { return __('General Information'); diff --git a/Block/Adminhtml/Sizechart/Edit/Tabs.php b/Block/Adminhtml/Sizechart/Edit/Tabs.php index 39fb5ea..b2b2e03 100644 --- a/Block/Adminhtml/Sizechart/Edit/Tabs.php +++ b/Block/Adminhtml/Sizechart/Edit/Tabs.php @@ -1,8 +1,8 @@ toHtml(), ] ); - + return parent::_beforeToHtml(); } -} +} \ No newline at end of file diff --git a/Block/Product/Sizechart.php b/Block/Product/Sizechart.php index b41baf0..91b64c3 100644 --- a/Block/Product/Sizechart.php +++ b/Block/Product/Sizechart.php @@ -18,9 +18,7 @@ class Sizechart extends \Magento\Catalog\Block\Product\AbstractProduct * @var \Magiccart\Magicproduct\Model\Magicproduct */ protected $_sizechartFactory; - protected $_limit; // Limit Product - protected $_parameters; // Condition Product protected $_request; protected $_abstractProduct; @@ -54,17 +52,17 @@ public function getSizeChartCollection() $store = $this->_storeManager->getStore()->getStoreId();; $collection = $this->_sizechartFactory->create()->getCollection() - ->addFieldToSelect('*') - ->addFieldToFilter('is_active', 1) - ->addFieldToFilter('stores', array(array('finset' => 0), array('finset' => $store))) - ->setOrder('sort_order', 'ASC'); + ->addFieldToSelect('*') + ->addFieldToFilter('is_active', 1) + ->addFieldToFilter('stores', array(array('finset' => 0), array('finset' => $store))) + ->setOrder('sort_order', 'ASC'); return $collection; } public function getSizeChart() { - if(!$this->hasData('size_chart')) { + if (!$this->hasData('size_chart')) { $collection = $this->getSizeChartCollection(); $product = $this->getProduct(); @@ -75,7 +73,7 @@ public function getSizeChart() $parameters = $data['parameters']; $rule = $this->getRule($parameters); $validate = $rule->getConditions()->validate($product); - if($validate){ + if ($validate) { $sizeChart = $item; break; } @@ -99,7 +97,7 @@ public function getClass($typeDisplay) $type = 'sizechart-inline'; } elseif ($typeDisplay == 2) { $type = 'sizechart-popup'; - } + } return $type; } @@ -111,11 +109,10 @@ protected function getRule($conditions) return $rule; } - public function getMedia($img = null) { $urlMedia = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); if ($img) return $urlMedia . "magepow/sizechart/" . $img; return $urlMedia; } -} +} \ No newline at end of file diff --git a/Controller/Adminhtml/Action.php b/Controller/Adminhtml/Action.php index 017d5b2..1001566 100644 --- a/Controller/Adminhtml/Action.php +++ b/Controller/Adminhtml/Action.php @@ -2,32 +2,32 @@ namespace Magepow\Sizechart\Controller\Adminhtml; -abstract class Action extends \Magento\Backend\App\Action{ +abstract class Action extends \Magento\Backend\App\Action +{ /** * Core registry * * @var \Magento\Framework\Registry */ protected $coreRegistry = null; - + /** * @var \Magento\Framework\App\Response\Http\FileFactory */ protected $fileFactory; - + /** * @var \Magento\Framework\Stdlib\DateTime\Filter\Date */ protected $dateFilter; - - + protected $_sizechartFactory; - + /** * @var \Psr\Log\LoggerInterface */ protected $logger; - + /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry @@ -50,7 +50,7 @@ public function __construct( $this->_sizechartFactory = $sizechartFactory; $this->logger = $logger; } - + /** * Initiate rule * @@ -60,14 +60,12 @@ protected function _initRule() { $rule = $this->_sizechartFactory->create(); $id = (int)$this->getRequest()->getParam('id'); - + if (!$id && $this->getRequest()->getParam('entity_id')) { $id = (int)$this->getRequest()->getParam('entity_id'); } - } - - + protected function _initAction() { $this->_view->loadLayout(); @@ -75,7 +73,7 @@ protected function _initAction() ->_addBreadcrumb(__('Magepow Sizechart'), __('Magepow Sizechart')); return $this; } - + /** * Returns result of current user permission check on resource and privilege * diff --git a/Controller/Adminhtml/Sizechart/AddRow.php b/Controller/Adminhtml/Sizechart/AddRow.php index a53f6e8..c7a1bda 100644 --- a/Controller/Adminhtml/Sizechart/AddRow.php +++ b/Controller/Adminhtml/Sizechart/AddRow.php @@ -55,4 +55,4 @@ public function execute() return $resultPage; } -} +} \ No newline at end of file diff --git a/Controller/Adminhtml/Sizechart/Index.php b/Controller/Adminhtml/Sizechart/Index.php index b42a91a..f8b09fc 100644 --- a/Controller/Adminhtml/Sizechart/Index.php +++ b/Controller/Adminhtml/Sizechart/Index.php @@ -1,4 +1,5 @@ resultPageFactory = $resultPageFactory; } @@ -21,6 +21,4 @@ public function execute() return $resultPage; } - - } \ No newline at end of file diff --git a/Controller/Adminhtml/Sizechart/MassDelete.php b/Controller/Adminhtml/Sizechart/MassDelete.php index 7dc9501..9042d3f 100644 --- a/Controller/Adminhtml/Sizechart/MassDelete.php +++ b/Controller/Adminhtml/Sizechart/MassDelete.php @@ -31,7 +31,6 @@ public function __construct( parent::__construct($context); } - public function execute() { $collection = $this->_filter->getCollection($this->_collectionFactory->create()); @@ -41,8 +40,10 @@ public function execute() $record->delete(); $recordDeleted++; } - $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', - $recordDeleted)); + $this->messageManager->addSuccess(__( + 'A total of %1 record(s) have been deleted.', + $recordDeleted + )); return $this->resultFactory->create(ResultFactory::TYPE_REDIRECT)->setPath('*/*/index'); } @@ -51,4 +52,4 @@ protected function _isAllowed() { return $this->_authorization->isAllowed('Magepow_Sizechart::row_data_delete'); } -} +} \ No newline at end of file diff --git a/Controller/Adminhtml/Sizechart/Save.php b/Controller/Adminhtml/Sizechart/Save.php index b87a762..319dae4 100644 --- a/Controller/Adminhtml/Sizechart/Save.php +++ b/Controller/Adminhtml/Sizechart/Save.php @@ -1,6 +1,7 @@ getRequest()->getParam('sizechart_id'); - if($id) $data['entity_id'] = $id; // fix conflict entity_id in product condition + if ($id) $data['entity_id'] = $id; // fix conflict entity_id in product condition $model = $this->_sizechartFactory->create(); $storeViewId = $this->getRequest()->getParam('stores'); $model->load($id); @@ -72,4 +73,4 @@ public function execute() return $resultRedirect->setPath('*/*/index'); } -} +} \ No newline at end of file diff --git a/Controller/Index/Index.php b/Controller/Index/Index.php index 9f48808..757fe13 100644 --- a/Controller/Index/Index.php +++ b/Controller/Index/Index.php @@ -1,4 +1,5 @@ _pageFactory = $pageFactory; $this->_sizechartFactory = $sizechartFactory; return parent::__construct($context); @@ -22,10 +22,9 @@ public function execute() { $page = $this->_pageFactory->create(); $pageFactory = $page->getLayout()->getBlock('Magepow\Sizechart\Block\Product\Sizechart'); - //We are using HTTP headers to control various page caches (varnish, fastly, built-in php cache) - $pageFactory->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0', true); + //We are using HTTP headers to control various page caches (varnish, fastly, built-in php cache) + $pageFactory->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, max-age=0', true); - return $pageFactory; + return $pageFactory; } - -} +} \ No newline at end of file diff --git a/Cron/Cron.php b/Cron/Cron.php index 64272ba..45c307e 100644 --- a/Cron/Cron.php +++ b/Cron/Cron.php @@ -9,8 +9,7 @@ class FlushCache public function __construct( \Magepow\Sizechart\Helper\Cache $helperCache - ) - { + ) { $this->helperCache = $helperCache; } diff --git a/Helper/Cache.php b/Helper/Cache.php index a024648..94d05a7 100644 --- a/Helper/Cache.php +++ b/Helper/Cache.php @@ -30,7 +30,8 @@ public function __construct( * Flush Cache Action * */ - public function flushCache() { + public function flushCache() + { $types = [ 'config', 'layout', diff --git a/Helper/Data.php b/Helper/Data.php index 9a55ec3..6f70465 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -9,38 +9,36 @@ class Data extends AbstractHelper { protected $configModule; protected $_moduleManager; - - public function __construct( + + public function __construct( \Magento\Framework\App\Helper\Context $context, - \Magento\Framework\Module\Manager $moduleManager - ) - { + \Magento\Framework\Module\Manager $moduleManager + ) { parent::__construct($context); $this->configModule = $this->getConfig(strtolower($this->_getModuleName())); $this->_moduleManager = $moduleManager; } - public function getConfig($cfg='') + public function getConfig($cfg = '') { - if($cfg) return $this->scopeConfig->getValue( $cfg, \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); + if ($cfg) return $this->scopeConfig->getValue($cfg, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); return $this->scopeConfig; } - public function getConfigModule($cfg='', $value=null) + public function getConfigModule($cfg = '', $value = null) { $values = $this->configModule; - if( !$cfg ) return $values; + if (!$cfg) return $values; $config = explode('/', (string) $cfg); $end = count($config) - 1; foreach ($config as $key => $vl) { - if( isset($values[$vl]) ){ - if( $key == $end ) { + if (isset($values[$vl])) { + if ($key == $end) { $value = $values[$vl]; - }else { + } else { $values = $values[$vl]; } - } - + } } return $value; } diff --git a/Model/Cron.php b/Model/Cron.php index 9f48ab0..1b1894a 100644 --- a/Model/Cron.php +++ b/Model/Cron.php @@ -1,23 +1,25 @@ _cacheTypeList = $cacheTypeList; $this->_cacheFrontendPool = $cacheFrontendPool; } - public function flushCache() { + public function flushCache() + { $types = [ 'config', 'layout', @@ -39,4 +41,4 @@ public function flushCache() { $cacheFrontend->getBackend()->clean(); } } -} +} \ No newline at end of file diff --git a/Model/ResourceModel/Sizechart.php b/Model/ResourceModel/Sizechart.php index 3dbb5db..7e1f82d 100644 --- a/Model/ResourceModel/Sizechart.php +++ b/Model/ResourceModel/Sizechart.php @@ -1,19 +1,17 @@ _init('sizechart_management', 'entity_id'); } - } \ No newline at end of file diff --git a/Model/ResourceModel/Sizechart/Collection.php b/Model/ResourceModel/Sizechart/Collection.php index 8d996a8..0be669c 100644 --- a/Model/ResourceModel/Sizechart/Collection.php +++ b/Model/ResourceModel/Sizechart/Collection.php @@ -1,4 +1,5 @@ _init('Magepow\Sizechart\Model\Sizechart', - 'Magepow\Sizechart\Model\ResourceModel\Sizechart'); + $this->_init( + 'Magepow\Sizechart\Model\Sizechart', + 'Magepow\Sizechart\Model\ResourceModel\Sizechart' + ); } - -} +} \ No newline at end of file diff --git a/Model/Sizechart.php b/Model/Sizechart.php index 7bf7b4f..20fb13d 100644 --- a/Model/Sizechart.php +++ b/Model/Sizechart.php @@ -1,102 +1,151 @@ _init('Magepow\Sizechart\Model\ResourceModel\Sizechart'); - } - + protected function _construct() + { + $this->_init('Magepow\Sizechart\Model\ResourceModel\Sizechart'); + } + + public function getIdentities() + { + return [self::CACHE_TAG . '_' . $this->getId()]; + } - public function getIdentities() - { - return [self::CACHE_TAG . '_' . $this->getId()]; - } + public function getDefaultValues() + { + $values = []; - public function getDefaultValues() - { - $values = []; + return $values; + } - return $values; - } - public function getEntityId() + public function getEntityId() { return $this->getData(self::ENTITY_ID); } - public function setEntityId($entityId){ - return $this->setData(self::ENTITY_ID,$entityId); + + public function setEntityId($entityId) + { + return $this->setData(self::ENTITY_ID, $entityId); } - public function getCategoryId(){ - return $this->getData(self::CATEGORY_ID); + + public function getCategoryId() + { + return $this->getData(self::CATEGORY_ID); } - public function setCategoryId($categoryId){ - return $this->setData(self::CATEGORY_ID,$categoryId); + + public function setCategoryId($categoryId) + { + return $this->setData(self::CATEGORY_ID, $categoryId); } - public function getSubCategoryId(){ - return $this->getData(self::SUB_CATEGORY_ID); + + public function getSubCategoryId() + { + return $this->getData(self::SUB_CATEGORY_ID); } - public function setSubCategoryId($subCategoryId){ - return $this->setData(self::SUB_CATEGORY_ID,$subCategoryId); + + public function setSubCategoryId($subCategoryId) + { + return $this->setData(self::SUB_CATEGORY_ID, $subCategoryId); } - public function getTypeDisplay(){ - return $this->getData(self::TYPE_DISPLAY); + + public function getTypeDisplay() + { + return $this->getData(self::TYPE_DISPLAY); } - public function setTypeDisplay($typeDisplay){ - return $this->setData(self::TYPE_DISPLAY, $typeDisplay); + + public function setTypeDisplay($typeDisplay) + { + return $this->setData(self::TYPE_DISPLAY, $typeDisplay); } - public function getDescription(){ - return $this->getData(self::DESCRIPTION); + + public function getDescription() + { + return $this->getData(self::DESCRIPTION); } - public function setDescription($description){ - return $this->setData(self::DESCRIPTION,$description); + + public function setDescription($description) + { + return $this->setData(self::DESCRIPTION, $description); } - public function getSizeChartInfo(){ - return $this->getData(self::SIZECHART_INFO); + + public function getSizeChartInfo() + { + return $this->getData(self::SIZECHART_INFO); } - public function setSizeChartInfo($sizeChartInfo){ - return $this->setData(self::SIZECHART_INFO,$sizeChartInfo); + + public function setSizeChartInfo($sizeChartInfo) + { + return $this->setData(self::SIZECHART_INFO, $sizeChartInfo); } - public function getUpdatedAt(){ - return $this->getData(self::UPDATED_AT); + + public function getUpdatedAt() + { + return $this->getData(self::UPDATED_AT); } - public function setUpdatedAt($updatedAt){ - return $this->setData(self::UPDATED_AT, $updatedAt); + + public function setUpdatedAt($updatedAt) + { + return $this->setData(self::UPDATED_AT, $updatedAt); } - public function getCreatedAt(){ - return $this->getData(self::CREATED_AT); + + public function getCreatedAt() + { + return $this->getData(self::CREATED_AT); } - public function setCreatedAt($createdAt){ - return $this->setData(self::CREATED_AT,$createdAt); + + public function setCreatedAt($createdAt) + { + return $this->setData(self::CREATED_AT, $createdAt); } - public function getIsActive(){ + + public function getIsActive() + { return $this->getData(self::IS_ACTIVE); } - public function setIsActive($isActive){ - return $this->setData(self::IS_ACTIVE,$isActive); + + public function setIsActive($isActive) + { + return $this->setData(self::IS_ACTIVE, $isActive); } - public function getTemplateCss(){ + + public function getTemplateCss() + { return $this->getData(self::TEMPLATE_CSS); } - public function setTemplateCss($templateCss){ - return $this->setData(self::TEMPLATE_CSS,$templateCss); + + public function setTemplateCss($templateCss) + { + return $this->setData(self::TEMPLATE_CSS, $templateCss); } - public function getConditions(){ + + public function getConditions() + { return $this->getData(self::CONDITIONS); } - public function setConditions($conditions){ + + public function setConditions($conditions) + { return $this->setData(self::CONDITIONS, $conditions); } - public function getStoreView(){ + + public function getStoreView() + { return $this->getData(self::STORES); } - public function setStoreView($stores){ + + public function setStoreView($stores) + { return $this->setData(self::STORES, $stores); } } \ No newline at end of file diff --git a/Model/Status.php b/Model/Status.php index 852f7eb..00b8667 100644 --- a/Model/Status.php +++ b/Model/Status.php @@ -1,15 +1,17 @@ - __('Enabled'),'0' => __('Disabled')]; + $options = ['1' => __('Enabled'), '0' => __('Disabled')]; return $options; } - + /** * Get Grid row status labels array with empty value for option element. * @@ -21,7 +23,7 @@ public function getAllOptions() array_unshift($res, ['value' => '', 'label' => '']); return $res; } - + /** * Get Grid row type array for option element. * @return array @@ -34,7 +36,7 @@ public function getOptions() } return $res; } - + /** * {@inheritdoc} */ diff --git a/Model/TypeDisplay.php b/Model/TypeDisplay.php index eeca89a..f7ad5a9 100644 --- a/Model/TypeDisplay.php +++ b/Model/TypeDisplay.php @@ -1,16 +1,18 @@ - __('Inline'),'2' => __('Pop Up'), '3'=>__('Custom Tab')]; + $options = ['1' => __('Inline'), '2' => __('Pop Up'), '3' => __('Custom Tab')]; return $options; } - + /** * Get Grid row status labels array with empty value for option element. * @@ -22,7 +24,7 @@ public function getAllOptions() array_unshift($res, ['value' => '', 'label' => '']); return $res; } - + /** * Get Grid row type array for option element. * @return array @@ -35,7 +37,7 @@ public function getOptions() } return $res; } - + /** * {@inheritdoc} */ diff --git a/Serialize/Serializer/Json.php b/Serialize/Serializer/Json.php index 6fd41e3..bd4c850 100644 --- a/Serialize/Serializer/Json.php +++ b/Serialize/Serializer/Json.php @@ -1,12 +1,13 @@ is_serialized($string)){ + if ($this->is_serialized($string)) { $string = $this->serialize($string); } $result = json_decode($string, true); @@ -16,29 +17,24 @@ public function unserialize($string) return $result; } - function is_serialized($value, &$result = null) { // Bit of a give away this one - if (!is_string($value)) - { + if (!is_string($value)) { return false; } // Serialized false, return true. unserialize() returns false on an // invalid string or it could return false if the string is serialized // false, eliminate that possibility. - if ($value === 'b:0;') - { + if ($value === 'b:0;') { $result = false; return true; } $length = strlen($value); $end = ''; - switch ($value[0]) - { + switch ($value[0]) { case 's': - if ($value[$length - 2] !== '"') - { + if ($value[$length - 2] !== '"') { return false; } case 'b': @@ -49,12 +45,10 @@ function is_serialized($value, &$result = null) case 'a': case 'O': $end .= '}'; - if ($value[1] !== ':') - { + if ($value[1] !== ':') { return false; } - switch ($value[2]) - { + switch ($value[2]) { case 0: case 1: case 2: @@ -71,16 +65,14 @@ function is_serialized($value, &$result = null) } case 'N': $end .= ';'; - if ($value[$length - 1] !== $end[0]) - { + if ($value[$length - 1] !== $end[0]) { return false; } break; default: return false; } - if (($result = json_decode($value)) === false) - { + if (($result = json_decode($value)) === false) { $result = null; return false; } diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php index 58534ed..5146089 100644 --- a/Setup/InstallSchema.php +++ b/Setup/InstallSchema.php @@ -1,6 +1,7 @@ startSetup(); - if (!$installer->tableExists('sizechart_management')){ - $table = $installer->getConnection() - ->newTable($installer->getTable('sizechart_management')); - $table->addColumn( - 'entity_id', - Table::TYPE_INTEGER, - null, - [ - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true - ], - 'ENTITY ID' - ) ->addColumn( - 'name', - Table::TYPE_TEXT, - '2M', - [], - 'Name' - ) - ->addColumn( - 'category', - Table::TYPE_TEXT, - null, - [], - 'category' - ) - ->addColumn( - 'type_display', - Table::TYPE_INTEGER, - null, - ['nullable'=>false,'default'=>1], - 'Size chart size display' - ) - ->addColumn( - 'is_active', + if (!$installer->tableExists('sizechart_management')) { + $table = $installer->getConnection() + ->newTable($installer->getTable('sizechart_management')); + $table->addColumn( + 'entity_id', Table::TYPE_INTEGER, null, [ + 'identity' => true, + 'unsigned' => true, 'nullable' => false, - 'default' => '1', + 'primary' => true ], - 'Is Active status' - ) - ->addColumn( - 'description', - Table::TYPE_TEXT, - '64k', - [], - 'Description' - ) - ->addColumn( - 'sizechart_info', + 'ENTITY ID' + )->addColumn( + 'name', Table::TYPE_TEXT, '2M', [], - 'Size Chart Information' - )->addColumn('conditions_serialized', Table::TYPE_TEXT, '2M', [], - 'Conditions Serialized') - ->addColumn('sort_order', Table::TYPE_INTEGER, null, [ 'nullable' => false, 'default' => '0'], - 'Sort Order') - ->addColumn( - 'updated_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], - 'Updated At' + 'Name' ) - ->addColumn( - 'created_at', - \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, - null, - ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], - 'Creation Time' - ); - $installer->getConnection()->createTable($table); - $installer->getConnection()->addIndex( + ->addColumn( + 'category', + Table::TYPE_TEXT, + null, + [], + 'category' + ) + ->addColumn( + 'type_display', + Table::TYPE_INTEGER, + null, + ['nullable' => false, 'default' => 1], + 'Size chart size display' + ) + ->addColumn( + 'is_active', + Table::TYPE_INTEGER, + null, + [ + 'nullable' => false, + 'default' => '1', + ], + 'Is Active status' + ) + ->addColumn( + 'description', + Table::TYPE_TEXT, + '64k', + [], + 'Description' + ) + ->addColumn( + 'sizechart_info', + Table::TYPE_TEXT, + '2M', + [], + 'Size Chart Information' + )->addColumn( + 'conditions_serialized', + Table::TYPE_TEXT, + '2M', + [], + 'Conditions Serialized' + ) + ->addColumn( + 'sort_order', + Table::TYPE_INTEGER, + null, + ['nullable' => false, 'default' => '0'], + 'Sort Order' + ) + ->addColumn( + 'updated_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT_UPDATE], + 'Updated At' + ) + ->addColumn( + 'created_at', + \Magento\Framework\DB\Ddl\Table::TYPE_TIMESTAMP, + null, + ['nullable' => false, 'default' => \Magento\Framework\DB\Ddl\Table::TIMESTAMP_INIT], + 'Creation Time' + ); + $installer->getConnection()->createTable($table); + $installer->getConnection()->addIndex( $installer->getTable('sizechart_management'), $setup->getIdxName( $installer->getTable('sizechart_management'), - ['name', 'description','sizechart_info'], + ['name', 'description', 'sizechart_info'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT ), - ['name', 'description','sizechart_info'], + ['name', 'description', 'sizechart_info'], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT ); - } - + $installer->endSetup(); - - } -} +} \ No newline at end of file diff --git a/Setup/UpgradeSchema.php b/Setup/UpgradeSchema.php index 1ecead9..a981644 100644 --- a/Setup/UpgradeSchema.php +++ b/Setup/UpgradeSchema.php @@ -1,5 +1,7 @@ startSetup(); + $setup->startSetup(); $tableName = $setup->getTable('sizechart_management'); if (version_compare($context->getVersion(), '2.0.0', '<')) { - if ($setup->getConnection()->isTableExists($tableName) == true){ + if ($setup->getConnection()->isTableExists($tableName) == true) { $connection = $setup->getConnection(); $connection->addColumn( - $setup->getTable($tableName),'template_css',[ + $setup->getTable($tableName), + 'template_css', + [ 'type' => Table::TYPE_TEXT, 'length' => '2M', 'nullable' => true, - 'comment'=>'template css'] + 'comment' => 'template css' + ] ); - } } if (version_compare($context->getVersion(), '2.3.0', '<')) { - if ($setup->getConnection()->isTableExists($tableName) == true){ + if ($setup->getConnection()->isTableExists($tableName) == true) { $connection = $setup->getConnection(); $connection->addColumn( - $setup->getTable($tableName),'stores',[ - 'type' => Table::TYPE_TEXT, - 'length' => '2M', - 'nullable' => false, - 'comment'=>'Store Views' - ] + $setup->getTable($tableName), + 'stores', + [ + 'type' => Table::TYPE_TEXT, + 'length' => '2M', + 'nullable' => false, + 'comment' => 'Store Views' + ] ); } } - } } \ No newline at end of file diff --git a/etc/acl.xml b/etc/acl.xml index 1655120..d8f992f 100644 --- a/etc/acl.xml +++ b/etc/acl.xml @@ -2,8 +2,8 @@ - - + + diff --git a/etc/adminhtml/menu.xml b/etc/adminhtml/menu.xml index f14dc26..889bff6 100644 --- a/etc/adminhtml/menu.xml +++ b/etc/adminhtml/menu.xml @@ -2,10 +2,9 @@ - - + + - + \ No newline at end of file diff --git a/etc/di.xml b/etc/di.xml index f7b13b4..fdf6b02 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -8,9 +8,8 @@ - - + + sizechart_management Magepow\Sizechart\Model\ResourceModel\Sizechart diff --git a/etc/module.xml b/etc/module.xml index 043a6fd..8fbe90b 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -8,6 +8,6 @@ - + \ No newline at end of file