_customerSession = $customerSession;
32 | $this->scopeConfig = $scopeConfig;
33 | parent::__construct($context);
34 | }
35 | public function allowExtension() {
36 | return $this->scopeConfig->getValue('jnext_mega_config/general/enabledisable', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
37 | }
38 | public function getCatLabel1Bgolor() {
39 | return $this->scopeConfig->getValue('jnext_mega_config/category_labels/category_label1_bgcolor', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
40 | }
41 | public function getCatLabel2Bgolor() {
42 | return $this->scopeConfig->getValue('jnext_mega_config/category_labels/category_label2_bgcolor', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
43 | }
44 | public function getCatLabel3Bgolor() {
45 | return $this->scopeConfig->getValue('jnext_mega_config/category_labels/category_label3_bgcolor', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
46 | }
47 | public function getCatLabel4Bgolor() {
48 | return $this->scopeConfig->getValue('jnext_mega_config/category_labels/category_label4_bgcolor', ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
49 | }
50 | public function getCatLabel($label) {
51 | return $this->scopeConfig->getValue('jnext_mega_config/category_labels/'.$label, ScopeConfigInterface::SCOPE_TYPE_DEFAULT);
52 | }
53 | }
--------------------------------------------------------------------------------
/view/frontend/templates/html/topmenu.phtml:
--------------------------------------------------------------------------------
1 |
8 | getColumnsLimit() ?: 0; ?>
9 | getHtml('level-top', 'submenu', $columnsLimit) ?>
10 | getHtml2('level-top', 'submenu', $columnsLimit) ?>
11 | allowExtension()): ?>
12 | get('Jnext\Megamenu\Helper\Data');
15 | $catLabel1Bgcolor = $helper->getCatLabel1Bgolor();
16 | $catLabel2Bgcolor = $helper->getCatLabel2Bgolor();
17 | $catLabel3Bgcolor = $helper->getCatLabel3Bgolor();
18 | $catLabel4Bgcolor = $helper->getCatLabel4Bgolor();
19 | ?>
20 |
30 |
31 |
35 |
36 |
37 | getChildHtml(); ?>
38 |
39 |
40 |
41 |
42 |
43 |
44 | getChildHtml(); ?>
45 |
46 |
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Jnext Magento2 MegaMenu
2 | Features
3 |
4 | Compatible with both Magento2 series 2.0 (latest version 2.0.11) and 2.1 (latest version 2.1.3)
5 | The plugin is one of the best ways to improve usability and navigation of your online store.
6 | Without high technical knowledge, Easy Mega Menu give you the ability to create an organized menu
7 | You have a lot of products, give a best user experience to customer
8 | Helps you attract more customers, by the way, you help customers save time, view shop easily and purchase quickly.
9 | Admin has the power to redirect visitors to where they want with nice gui
10 | Auto converts to default menu in tablet and smaller devices
11 | Attracts visitors' attention at first sight with great design
12 | Easy to use even without coding skills
13 |
14 | Usage
15 | Easy navigation menu at left side having 2 submenus "Manage Megamenu" and "Configurations"
16 |
17 | Manage Megamenu: Redirects to "Manage Categories" having "Megamenu" tab added
18 |
19 | Can configure selected categories as mega-menu and rest as default-menu as per admin convenience
20 | Flexibility to select from different sections top, left, right and bottom
21 | Flexibility to display eighter static/dynamic content from already created static block or can add manual html using magento standard WYSIWYG Editor
22 | Can select width of left, right sections and whole-menu from all possible volume in percentage
23 | Can upload extra category image named category thumbnail image
24 | Left section has options to display like subcategories menu, subcategories expanded (all children categories visible) and subcategories with category thumbnail
25 | Selection of category label configured earlier like SALE, NEW, HOT etc.
26 |
27 |
28 | Configurations: Redirects to sytem configuration to configure the plugin like:
29 |
30 | Enable/Disable the plugin
31 | Add category label with nice gui of color picker for category label
32 |
33 |
34 |
35 | Install
36 | This package is registered on Packagist for easy installation. In your Magento installation root run:
37 | composer require jnext/megamenu
38 | This will install the latest version in your Magento installation, when completed run:
39 | php bin/magento module:enable Jnext_Megamenu
40 |
41 | php bin/magento setup:upgrade
42 |
43 | php bin/magento cache:clean
44 |
45 | This will enable the extension and installs Megamenu tab with fields under Manage Categories
46 | Note:
47 | If you face error like
48 | Could not find package jnext/megamenu at any version for your minimum-stability (alpha). Check the package spelling or your minimum-stability
49 | To resolve, edit your composer.json file located at root of your project by setting "minimum-stability": from "alpha" to "dev"
50 |
--------------------------------------------------------------------------------
/etc/adminhtml/system.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Jnext Megamenu
6 |
7 |
8 | separator-top
9 | Settings
10 | jnext_config
11 | Jnext_Megamenu::jnext_mega_config
12 |
13 | General Settings
14 |
15 |
16 | Enabled
17 | Magento\Config\Model\Config\Source\Yesno
18 |
19 |
20 |
21 |
22 | Category Labels
23 | These category labels will be selectable from <b>Products > Inventory > Categories > Megamenu tab </b>
24 |
25 | Label 1
26 |
27 |
28 |
29 | Background Color
30 |
31 | Jnext\Megamenu\Block\Color
32 |
33 |
34 | Label 2
35 |
36 |
37 |
38 | Background Color
39 |
40 | Jnext\Megamenu\Block\Color
41 |
42 |
43 | Label 3
44 |
45 |
46 |
47 | Background Color
48 |
49 | Jnext\Megamenu\Block\Color
50 |
51 |
52 | Label 4
53 |
54 |
55 |
56 | Background Color
57 |
58 | Jnext\Megamenu\Block\Color
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/view/frontend/web/js/jquery-dcmegamenu.js:
--------------------------------------------------------------------------------
1 | (function($){$.fn.dcMegaMenu=function(options){var defaults={classParent:'dc-mega',classContainer:'sub-container',classSubParent:'mega-hdr',classSubLink:'mega-hdr',classWidget:'dc-extra',rowItems:3,speed:'fast',effect:'fade',rtl:false,event:'hover',fullWidth:false,onLoad:function(){},beforeOpen:function(){},beforeClose:function(){}};var options=$.extend(defaults,options);var $dcMegaMenuObj=this;return $dcMegaMenuObj.each(function(options){var clSubParent=defaults.classSubParent;var clSubLink=defaults.classSubLink;var clParent=defaults.classParent;var clContainer=defaults.classContainer;var clWidget=defaults.classWidget;megaSetup();function megaOver(){var subNav=$('.sub',this);$(this).addClass('mega-hover');if(defaults.effect=='fade'){$(subNav).fadeIn(defaults.speed)}if(defaults.effect=='slide'){$(subNav).show(defaults.speed)}defaults.beforeOpen.call(this)}function megaAction(obj){var subNav=$('.sub',obj);$(obj).addClass('mega-hover');if(defaults.effect=='fade'){$(subNav).fadeIn(defaults.speed)}if(defaults.effect=='slide'){$(subNav).show(defaults.speed)}defaults.beforeOpen.call(this)}function megaOut(){var subNav=$('.sub',this);$(this).removeClass('mega-hover');$(subNav).hide();defaults.beforeClose.call(this)}function megaActionClose(obj){var subNav=$('.sub',obj);$(obj).removeClass('mega-hover');$(subNav).hide();defaults.beforeClose.call(this)}function megaReset(){$('li',$dcMegaMenuObj).removeClass('mega-hover');$('.sub',$dcMegaMenuObj).hide()}function megaSetup(){$arrow=' ';var clParentLi=clParent+'-li';var menuWidth=$dcMegaMenuObj.outerWidth();$('> li',$dcMegaMenuObj).each(function(){var $mainSub=$('> ul',this);var $primaryLink=$('> a',this);if($mainSub.length){$primaryLink.addClass(clParent).append($arrow);$mainSub.addClass('sub').wrap('
');var pos=$(this).position();pl=pos.left;if($('ul',$mainSub).length){$(this).addClass(clParentLi);$('.'+clContainer,this).addClass('mega');$('> li',$mainSub).each(function(){if(!$(this).hasClass(clWidget)){$(this).addClass('mega-unit');if($('> ul',this).length){$(this).addClass(clSubParent);$('> a',this).addClass(clSubParent+'-a')}else{$(this).addClass(clSubLink);$('> a',this).addClass(clSubLink+'-a')}}});var hdrs=$('.mega-unit',this);rowSize=parseInt(defaults.rowItems);for(var i=0;i ')}$mainSub.show();var pw=$(this).width();var pr=pl+pw;var mr=menuWidth-pr;var subw=$mainSub.outerWidth();var totw=$mainSub.parent('.'+clContainer).outerWidth();var cpad=totw-subw;if(defaults.fullWidth==true){var fw=menuWidth-cpad;$mainSub.parent('.'+clContainer).css({width:fw+'px'});$dcMegaMenuObj.addClass('full-width')}var iw=$('.mega-unit',$mainSub).outerWidth(true);var rowItems=$('.row:eq(0) .mega-unit',$mainSub).length;var inneriw=iw*rowItems;var totiw=inneriw+cpad;$('.row',this).each(function(){$('.mega-unit:last',this).addClass('last');var maxValue=undefined;$('.mega-unit > a',this).each(function(){var val=parseInt($(this).height());if(maxValue===undefined||maxValue a',this).css('height',maxValue+'px');$(this).css('width',inneriw+'px')});if(defaults.fullWidth==true){params={left:0}}else{var ml=mr li > a',$dcMegaMenuObj).outerHeight(true);$('.'+clContainer,$dcMegaMenuObj).css({top:menuHeight+'px'}).css('z-index','1000');if(defaults.event=='hover'){var config={sensitivity:2,interval:100,over:megaOver,timeout:400,out:megaOut};$('li',$dcMegaMenuObj).hoverIntent(config)}if(defaults.event=='click'){$('body').mouseup(function(e){if(!$(e.target).parents('.mega-hover').length){megaReset()}});$('> li > a.'+clParent,$dcMegaMenuObj).click(function(e){var $parentLi=$(this).parent();if($parentLi.hasClass('mega-hover')){megaActionClose($parentLi)}else{megaAction($parentLi)}e.preventDefault()})}defaults.onLoad.call(this)}})}})(jQuery);
--------------------------------------------------------------------------------
/view/frontend/web/css/custom.css:
--------------------------------------------------------------------------------
1 | @media only screen and (max-width: 959px) {
2 | .navigation .megamenu {display: none;}
3 | .navigation #dm {display: block;}
4 | }
5 | @media only screen and (min-width: 960px) {
6 | .navigation .megamenu {display: block; }
7 | .navigation .megamenu .megamenu-wrapper {border-radius: 5px;}
8 | .navigation #dm {display: none;}
9 |
10 | .megamenu li.level0.mega {position: static;}
11 | .megamenu li.level0 a.level-top + .megamenu-wrapper
12 | {
13 | display: none;
14 | position: absolute;
15 | left: 0;
16 | top: 45px;
17 | background: #fff;
18 | z-index: 999;
19 | border: 1px solid #ccc;
20 | padding: 15px 15px 0px;
21 | min-width: 230px
22 | }
23 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_standard {width: 95%; }
24 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_20 {width: 20%; }
25 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_30 {width: 30%; }
26 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_40 {width: 40%; }
27 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_50 {width: 50%; }
28 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_60 {width: 60%; }
29 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_70 {width: 70%; }
30 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_80 {width: 80%; }
31 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_90 {width: 90%; }
32 | .megamenu li.level0 a.level-top + .megamenu-wrapper.width_100 {width: 95%; }
33 | .megamenu li.level0 a.level-top + .megamenu-wrapper .megamenu-block
34 | { margin-bottom: 20px; display: inline-block; float: left; vertical-align: top;}
35 | .megamenu li.level0 a.level-top + .megamenu-wrapper .topblock {width: 100%}
36 | .megamenu li.level0 a.level-top + .megamenu-wrapper .bottomblock {width: 100%}
37 | .megamenu .cat-label {
38 | color: #fff;
39 | font-size: 10px;
40 | font-weight: normal;
41 | padding: 0 5px;
42 | text-transform: none;
43 | vertical-align: middle;
44 | line-height: 16px;
45 | text-transform: uppercase;
46 | position: absolute;
47 | right: 20px;
48 | top: -20px;
49 | }
50 | .megamenu .active .cat-label {top: -5px }
51 | .megamenu .cat-label:before {
52 | border-color: transparent;
53 | border-style: solid;
54 | border-width: 4px;
55 | content: "";
56 | height: 0;
57 | position: absolute;
58 | right: 6px;
59 | top: 16px;
60 | width: 0;
61 | }
62 | /*----------------------------LEFT----------------------------*/
63 | .megamenu .leftblock {margin: 0 2% 2% 0;}
64 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock .level0.submenu
65 | {display: block !important; position: relative !important; box-shadow: none;}
66 | .megamenu .leftblock .submenu.level1 li {margin-bottom: 0px}
67 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_standard {width: 20%; }
68 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_20 {width: 20%; }
69 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_30 {width: 30%; }
70 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_40 {width: 40%; }
71 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_50 {width: 50%; }
72 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_60 {width: 60%; }
73 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_70 {width: 70%; }
74 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_80 {width: 80%; }
75 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_90 {width: 90%; }
76 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_100 {width: 100%; }
77 | /*----------------------------RIGHT----------------------------*/
78 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_standard {width: 78%; }
79 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_20 {width: 18%; }
80 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_30 {width: 28%; }
81 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_40 {width: 38%; }
82 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_50 {width: 48%; }
83 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_60 {width: 58%; }
84 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_70 {width: 68%; }
85 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_80 {width: 78%; }
86 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_90 {width: 88%; }
87 | .megamenu li.level0 a.level-top + .megamenu-wrapper .rightblock.width_100 {width: 100%; }
88 | /*----------------------------LEFT_DYNAMIC RIGHT_STANDARD COMBINED----------------------------*/
89 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_30
90 | + .rightblock.width_standard {width: 68%; }
91 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_40
92 | + .rightblock.width_standard {width: 58%; }
93 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_50
94 | + .rightblock.width_standard {width: 48%; }
95 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_60
96 | + .rightblock.width_standard {width: 38%; }
97 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_70
98 | + .rightblock.width_standard {width: 28%; }
99 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_80
100 | + .rightblock.width_standard {width: 18%; }
101 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_90
102 | + .rightblock.width_standard {width: 8%; }
103 | .megamenu li.level0 a.level-top + .megamenu-wrapper .leftblock.width_100
104 | + .rightblock.width_standard {width: 100%; }
105 |
106 | .megamenu li.level0 a.level-top.ui-state-focus + .megamenu-wrapper {display: block !important;}
107 | .megamenu li.level0 a.level-top.ui-state-active + .megamenu-wrapper {display: block !important;}
108 | .megamenu .megamenu-block > p {margin-bottom: 0; }
109 | .megamenu li.level0 a.level-top.ui-state-focus,
110 | .megamenu li.level0 a.level-top.ui-state-active {color: #ff5501}
111 |
112 | /*sub categories expanded*/
113 | .megamenu .leftblock.sub_expanded .submenu li.parent > a
114 | {color: #000; font-weight: 600; text-transform: uppercase;}
115 | .megamenu .leftblock.sub_expanded .submenu.level0 > li
116 | {display: inline-block; vertical-align: top; float: none; margin: 0 1% 1% 0}
117 | .megamenu .leftblock.sub_expanded > .submenu {border: none; box-shadow: none}
118 | .megamenu .leftblock.sub_expanded .submenu.level1
119 | {z-index: auto; display: block !important; left: 0 !important; position: relative; min-width: 200px}
120 | .megamenu .leftblock.sub_expanded .submenu.level2 {z-index: 2}
121 | .megamenu .leftblock.sub_expanded li.level2 a:before
122 | {content: '\e619'; font-family: "luma-icons"; font-size: 8px; font-weight: normal; padding-right: 5px; color: silver; }
123 | .megamenu .leftblock.sub_expanded .submenu.level0 .submenu {padding-left: 1em; }
124 | .megamenu .mega .leftblock.sub_expanded .submenu
125 | {border: medium none; box-shadow: none; display: block !important; position: relative; left: 0px !important}
126 | .megamenu .leftblock.sub_expanded .submenu li a {padding: 2px 4px; }
127 | .megamenu .leftblock.sub_expanded .submenu.level0 {border-right: 1px solid #ddd}
128 | /*sub categories expanded with image*/
129 | .megamenu .leftblock.sub_expanded_with_image .submenu li img
130 | {border: 1px solid #ddd; border-radius: 5px; display: inline-block; max-width: 25px; vertical-align: middle; margin-left: 10px; }
131 | /*sub categories menu*/
132 | .megamenu .leftblock.sub_menu > .submenu > li > a {padding: 10px 20px; }
133 | .megamenu .leftblock.sub_menu > .submenu > li {border-bottom: 1px solid #ccc; margin: 0; position: relative;}
134 | .megamenu .leftblock.sub_menu > .submenu > li:last-child {border-bottom: none;}
135 | .megamenu .leftblock.sub_menu > .submenu > li.parent > a > span.ui-icon:after
136 | {content: '\e619'; line-height: 20px; float: right; font-family: "luma-icons"; font-size: 10px;}
137 | .navigation .megamenu .level0 .submenu {z-index: 9}
138 | .megamenu li.level0 .submenu.level0 {min-width: initial;}
139 | .megamenu .mega .sub_expanded_with_image .submenu.level0 .submenu {min-width: initial;}
140 | .megamenu .leftblock.sub_menu > .submenu > li.parent .submenu li.parent > a > span:not(.ui-icon):after
141 | {
142 | color: inherit;
143 | content: '\e622';
144 | display: inline-block;
145 | font-family: "luma-icons";
146 | font-size: 10px;
147 | font-weight: normal;
148 | line-height: 12px;
149 | margin: 0 0 0 5px;
150 | overflow: hidden;
151 | text-align: center;
152 | vertical-align: middle;
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/view/frontend/web/js/modernizr-2.8.3.js:
--------------------------------------------------------------------------------
1 | /* Modernizr 2.8.3 (Custom Build) | MIT & BSD
2 | * Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-mq-cssclasses-addtest-prefixed-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
3 | */
4 | ;window.Modernizr=function(a,b,c){function D(a){j.cssText=a}function E(a,b){return D(n.join(a+";")+(b||""))}function F(a,b){return typeof a===b}function G(a,b){return!!~(""+a).indexOf(b)}function H(a,b){for(var d in a){var e=a[d];if(!G(e,"-")&&j[e]!==c)return b=="pfx"?e:!0}return!1}function I(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:F(f,"function")?f.bind(d||b):f}return!1}function J(a,b,c){var d=a.charAt(0).toUpperCase()+a.slice(1),e=(a+" "+p.join(d+" ")+d).split(" ");return F(b,"string")||F(b,"undefined")?H(e,b):(e=(a+" "+q.join(d+" ")+d).split(" "),I(e,b,c))}function K(){e.input=function(c){for(var d=0,e=c.length;d',a,""].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},z=function(b){var c=a.matchMedia||a.msMatchMedia;if(c)return c(b)&&c(b).matches||!1;var d;return y("@media "+b+" { #"+h+" { position: absolute; } }",function(b){d=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle)["position"]=="absolute"}),d},A=function(){function d(d,e){e=e||b.createElement(a[d]||"div"),d="on"+d;var f=d in e;return f||(e.setAttribute||(e=b.createElement("div")),e.setAttribute&&e.removeAttribute&&(e.setAttribute(d,""),f=F(e[d],"function"),F(e[d],"undefined")||(e[d]=c),e.removeAttribute(d))),e=null,f}var a={select:"input",change:"input",submit:"form",reset:"form",error:"img",load:"img",abort:"img"};return d}(),B={}.hasOwnProperty,C;!F(B,"undefined")&&!F(B.call,"undefined")?C=function(a,b){return B.call(a,b)}:C=function(a,b){return b in a&&F(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=w.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(w.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(w.call(arguments)))};return e}),s.flexbox=function(){return J("flexWrap")},s.canvas=function(){var a=b.createElement("canvas");return!!a.getContext&&!!a.getContext("2d")},s.canvastext=function(){return!!e.canvas&&!!F(b.createElement("canvas").getContext("2d").fillText,"function")},s.webgl=function(){return!!a.WebGLRenderingContext},s.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&&b instanceof DocumentTouch?c=!0:y(["@media (",n.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c},s.geolocation=function(){return"geolocation"in navigator},s.postmessage=function(){return!!a.postMessage},s.websqldatabase=function(){return!!a.openDatabase},s.indexedDB=function(){return!!J("indexedDB",a)},s.hashchange=function(){return A("hashchange",a)&&(b.documentMode===c||b.documentMode>7)},s.history=function(){return!!a.history&&!!history.pushState},s.draganddrop=function(){var a=b.createElement("div");return"draggable"in a||"ondragstart"in a&&"ondrop"in a},s.websockets=function(){return"WebSocket"in a||"MozWebSocket"in a},s.rgba=function(){return D("background-color:rgba(150,255,150,.5)"),G(j.backgroundColor,"rgba")},s.hsla=function(){return D("background-color:hsla(120,40%,100%,.5)"),G(j.backgroundColor,"rgba")||G(j.backgroundColor,"hsla")},s.multiplebgs=function(){return D("background:url(https://),url(https://),red url(https://)"),/(url\s*\(.*?){3}/.test(j.background)},s.backgroundsize=function(){return J("backgroundSize")},s.borderimage=function(){return J("borderImage")},s.borderradius=function(){return J("borderRadius")},s.boxshadow=function(){return J("boxShadow")},s.textshadow=function(){return b.createElement("div").style.textShadow===""},s.opacity=function(){return E("opacity:.55"),/^0.55$/.test(j.opacity)},s.cssanimations=function(){return J("animationName")},s.csscolumns=function(){return J("columnCount")},s.cssgradients=function(){var a="background-image:",b="gradient(linear,left top,right bottom,from(#9f9),to(white));",c="linear-gradient(left top,#9f9, white);";return D((a+"-webkit- ".split(" ").join(b+a)+n.join(c+a)).slice(0,-a.length)),G(j.backgroundImage,"gradient")},s.cssreflections=function(){return J("boxReflect")},s.csstransforms=function(){return!!J("transform")},s.csstransforms3d=function(){var a=!!J("perspective");return a&&"webkitPerspective"in g.style&&y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}",function(b,c){a=b.offsetLeft===9&&b.offsetHeight===3}),a},s.csstransitions=function(){return J("transition")},s.fontface=function(){var a;return y('@font-face {font-family:"font";src:url("https://")}',function(c,d){var e=b.getElementById("smodernizr"),f=e.sheet||e.styleSheet,g=f?f.cssRules&&f.cssRules[0]?f.cssRules[0].cssText:f.cssText||"":"";a=/src/i.test(g)&&g.indexOf(d.split(" ")[0])===0}),a},s.generatedcontent=function(){var a;return y(["#",h,"{font:0/0 a}#",h,':after{content:"',l,'";visibility:hidden;font:3px/1 a}'].join(""),function(b){a=b.offsetHeight>=3}),a},s.video=function(){var a=b.createElement("video"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/,""),c.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/,""),c.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/,"")}catch(d){}return c},s.audio=function(){var a=b.createElement("audio"),c=!1;try{if(c=!!a.canPlayType)c=new Boolean(c),c.ogg=a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,""),c.mp3=a.canPlayType("audio/mpeg;").replace(/^no$/,""),c.wav=a.canPlayType('audio/wav; codecs="1"').replace(/^no$/,""),c.m4a=(a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")).replace(/^no$/,"")}catch(d){}return c},s.localstorage=function(){try{return localStorage.setItem(h,h),localStorage.removeItem(h),!0}catch(a){return!1}},s.sessionstorage=function(){try{return sessionStorage.setItem(h,h),sessionStorage.removeItem(h),!0}catch(a){return!1}},s.webworkers=function(){return!!a.Worker},s.applicationcache=function(){return!!a.applicationCache},s.svg=function(){return!!b.createElementNS&&!!b.createElementNS(r.svg,"svg").createSVGRect},s.inlinesvg=function(){var a=b.createElement("div");return a.innerHTML=" ",(a.firstChild&&a.firstChild.namespaceURI)==r.svg},s.smil=function(){return!!b.createElementNS&&/SVGAnimate/.test(m.call(b.createElementNS(r.svg,"animate")))},s.svgclippaths=function(){return!!b.createElementNS&&/SVGClipPath/.test(m.call(b.createElementNS(r.svg,"clipPath")))};for(var L in s)C(s,L)&&(x=L.toLowerCase(),e[x]=s[L](),v.push((e[x]?"":"no-")+x));return e.input||K(),e.addTest=function(a,b){if(typeof a=="object")for(var d in a)C(a,d)&&e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&&f&&(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},D(""),i=k=null,function(a,b){function l(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function m(){var a=s.elements;return typeof a=="string"?a.split(" "):a}function n(a){var b=j[a[h]];return b||(b={},i++,a[h]=i,j[i]=b),b}function o(a,c,d){c||(c=b);if(k)return c.createElement(a);d||(d=n(c));var g;return d.cache[a]?g=d.cache[a].cloneNode():f.test(a)?g=(d.cache[a]=d.createElem(a)).cloneNode():g=d.createElem(a),g.canHaveChildren&&!e.test(a)&&!g.tagUrn?d.frag.appendChild(g):g}function p(a,c){a||(a=b);if(k)return a.createDocumentFragment();c=c||n(a);var d=c.frag.cloneNode(),e=0,f=m(),g=f.length;for(;e",g="hidden"in a,k=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){g=!0,k=!0}})();var s={elements:d.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",version:c,shivCSS:d.shivCSS!==!1,supportsUnknownElements:k,shivMethods:d.shivMethods!==!1,type:"default",shivDocument:r,createElement:o,createDocumentFragment:p};a.html5=s,r(b)}(this,b),e._version=d,e._prefixes=n,e._domPrefixes=q,e._cssomPrefixes=p,e.mq=z,e.hasEvent=A,e.testProp=function(a){return H([a])},e.testAllProps=J,e.testStyles=y,e.prefixed=function(a,b,c){return b?J(a,b,c):J(a,"pfx")},g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+v.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;fcategorySetupFactory = $categorySetupFactory;
27 | }
28 | /**
29 | * {@inheritdoc}
30 | * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
31 | */
32 | public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
33 | {
34 | $installer = $setup;
35 |
36 | $installer->startSetup();
37 |
38 | $categorySetup = $this->categorySetupFactory->create(['setup' => $setup]);
39 | $entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Category::ENTITY);
40 | $attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId);
41 | $megaAttributeGroup = $categorySetup->addAttributeGroup($entityTypeId, $attributeSetId, 'Megamenu','1000');
42 |
43 | $categorySetup->addAttribute(
44 | \Magento\Catalog\Model\Category::ENTITY, 'mega_menu_type', [
45 | 'type' => 'varchar',
46 | 'label' => 'Menu Type',
47 | 'input' => 'select',
48 | 'source' => 'Jnext\Megamenu\Model\Category\Attribute\Source\Menutypes',
49 | 'required' => false,
50 | 'sort_order' => 1,
51 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
52 | 'group' => 'Megamenu',
53 | ]
54 | );
55 | $categorySetup->addAttribute(
56 | \Magento\Catalog\Model\Category::ENTITY, 'mega_menu_width', [
57 | 'type' => 'varchar',
58 | 'label' => 'Menu Width',
59 | 'input' => 'select',
60 | 'source' => 'Jnext\Megamenu\Model\Category\Attribute\Source\Blockwidth',
61 | 'required' => false,
62 | 'sort_order' => 2,
63 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
64 | 'group' => 'Megamenu',
65 | ]
66 | );
67 | $categorySetup->addAttribute(
68 | \Magento\Catalog\Model\Category::ENTITY, 'mega_category_label', [
69 | 'type' => 'varchar',
70 | 'label' => 'Category Label',
71 | 'input' => 'select',
72 | 'source' => 'Jnext\Megamenu\Model\Category\Attribute\Source\Categorylabels',
73 | 'required' => false,
74 | 'sort_order' => 3,
75 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
76 | 'group' => 'Megamenu',
77 | ]
78 | );
79 | $categorySetup->addAttribute(
80 | \Magento\Catalog\Model\Category::ENTITY, 'mega_category_thumbnail_image', [
81 | 'type' => 'varchar',
82 | 'label' => 'Category Thumbnail Image',
83 | 'input' => 'image',
84 | 'backend' => 'Magento\Catalog\Model\Category\Attribute\Backend\Image',
85 | 'required' => false,
86 | 'sort_order' => 4,
87 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
88 | 'group' => 'Megamenu',
89 | ]
90 | );
91 | //-----------------------------------------------TOP
92 | $categorySetup->addAttribute(
93 | \Magento\Catalog\Model\Category::ENTITY, 'mega_display_top_block', [
94 | 'type' => 'varchar',
95 | 'label' => 'Display Top Block?',
96 | 'input' => 'select',
97 | 'source' => 'Jnext\Megamenu\Model\Category\Attribute\Source\Blockoptions',
98 | 'required' => false,
99 | 'sort_order' => 5,
100 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
101 | 'group' => 'Megamenu',
102 | ]
103 | );
104 | $categorySetup->addAttribute(
105 | \Magento\Catalog\Model\Category::ENTITY, 'mega_top_block_id', [
106 | 'type' => 'int',
107 | 'label' => 'Selct Top Static Block',
108 | 'input' => 'select',
109 | 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Page',
110 | 'required' => false,
111 | 'sort_order' => 6,
112 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
113 | 'group' => 'Megamenu',
114 | ]
115 | );
116 | $categorySetup->addAttribute(
117 | \Magento\Catalog\Model\Category::ENTITY, 'mega_top_block_content', [
118 | 'type' => 'text',
119 | 'label' => 'Top Block Content',
120 | 'input' => 'textarea',
121 | 'required' => false,
122 | 'sort_order' => 7,
123 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
124 | 'wysiwyg_enabled' => true,
125 | 'is_html_allowed_on_front' => true,
126 | 'group' => 'Megamenu',
127 | ]
128 | );
129 | //-----------------------------------------------LEFT
130 | $categorySetup->addAttribute(
131 | \Magento\Catalog\Model\Category::ENTITY, 'mega_display_left_block', [
132 | 'type' => 'varchar',
133 | 'label' => 'Display Left Block?',
134 | 'input' => 'select',
135 | 'source' => 'Jnext\Megamenu\Model\Category\Attribute\Source\Leftblockoptions',
136 | 'required' => false,
137 | 'sort_order' => 8,
138 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
139 | 'group' => 'Megamenu',
140 | ]
141 | );
142 | $categorySetup->addAttribute(
143 | \Magento\Catalog\Model\Category::ENTITY, 'mega_left_block_id', [
144 | 'type' => 'int',
145 | 'label' => 'Selct Left Static Block',
146 | 'input' => 'select',
147 | 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Page',
148 | 'required' => false,
149 | 'sort_order' => 9,
150 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
151 | 'group' => 'Megamenu',
152 | ]
153 | );
154 | $categorySetup->addAttribute(
155 | \Magento\Catalog\Model\Category::ENTITY, 'mega_left_block_content', [
156 | 'type' => 'text',
157 | 'label' => 'Left Block Content',
158 | 'input' => 'textarea',
159 | 'required' => false,
160 | 'sort_order' => 10,
161 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
162 | 'wysiwyg_enabled' => true,
163 | 'is_html_allowed_on_front' => true,
164 | 'group' => 'Megamenu',
165 | ]
166 | );
167 | $categorySetup->addAttribute(
168 | \Magento\Catalog\Model\Category::ENTITY, 'mega_left_block_width', [
169 | 'type' => 'varchar',
170 | 'label' => 'Left Block Width',
171 | 'input' => 'select',
172 | 'source' => 'Jnext\Megamenu\Model\Category\Attribute\Source\Blockwidth',
173 | 'required' => false,
174 | 'sort_order' => 11,
175 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
176 | 'group' => 'Megamenu',
177 | ]
178 | );
179 | //-----------------------------------------------RIGHT
180 | $categorySetup->addAttribute(
181 | \Magento\Catalog\Model\Category::ENTITY, 'mega_display_right_block', [
182 | 'type' => 'varchar',
183 | 'label' => 'Display Right Block?',
184 | 'input' => 'select',
185 | 'source' => 'Jnext\Megamenu\Model\Category\Attribute\Source\Blockoptions',
186 | 'required' => false,
187 | 'sort_order' => 12,
188 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
189 | 'group' => 'Megamenu',
190 | ]
191 | );
192 | $categorySetup->addAttribute(
193 | \Magento\Catalog\Model\Category::ENTITY, 'mega_right_block_id', [
194 | 'type' => 'int',
195 | 'label' => 'Selct Right Static Block',
196 | 'input' => 'select',
197 | 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Page',
198 | 'required' => false,
199 | 'sort_order' => 13,
200 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
201 | 'group' => 'Megamenu',
202 | ]
203 | );
204 | $categorySetup->addAttribute(
205 | \Magento\Catalog\Model\Category::ENTITY, 'mega_right_block_content', [
206 | 'type' => 'text',
207 | 'label' => 'Right Block Content',
208 | 'input' => 'textarea',
209 | 'required' => false,
210 | 'sort_order' => 14,
211 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
212 | 'wysiwyg_enabled' => true,
213 | 'is_html_allowed_on_front' => true,
214 | 'group' => 'Megamenu',
215 | ]
216 | );
217 | $categorySetup->addAttribute(
218 | \Magento\Catalog\Model\Category::ENTITY, 'mega_right_block_width', [
219 | 'type' => 'varchar',
220 | 'label' => 'Right Block Width',
221 | 'input' => 'select',
222 | 'source' => 'Jnext\Megamenu\Model\Category\Attribute\Source\Blockwidth',
223 | 'required' => false,
224 | 'sort_order' => 15,
225 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
226 | 'group' => 'Megamenu',
227 | ]
228 | );
229 | //-----------------------------------------------BOTTOM
230 | $categorySetup->addAttribute(
231 | \Magento\Catalog\Model\Category::ENTITY, 'mega_display_bottom_block', [
232 | 'type' => 'varchar',
233 | 'label' => 'Display Bottom Block?',
234 | 'input' => 'select',
235 | 'source' => 'Jnext\Megamenu\Model\Category\Attribute\Source\Blockoptions',
236 | 'required' => false,
237 | 'sort_order' => 16,
238 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
239 | 'group' => 'Megamenu',
240 | ]
241 | );
242 | $categorySetup->addAttribute(
243 | \Magento\Catalog\Model\Category::ENTITY, 'mega_bottom_block_id', [
244 | 'type' => 'int',
245 | 'label' => 'Selct Bottom Static Block',
246 | 'input' => 'select',
247 | 'source' => 'Magento\Catalog\Model\Category\Attribute\Source\Page',
248 | 'required' => false,
249 | 'sort_order' => 17,
250 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
251 | 'group' => 'Megamenu',
252 | ]
253 | );
254 | $categorySetup->addAttribute(
255 | \Magento\Catalog\Model\Category::ENTITY, 'mega_bottom_block_content', [
256 | 'type' => 'text',
257 | 'label' => 'Bottom Block Content',
258 | 'input' => 'textarea',
259 | 'required' => false,
260 | 'sort_order' => 18,
261 | 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
262 | 'wysiwyg_enabled' => true,
263 | 'is_html_allowed_on_front' => true,
264 | 'group' => 'Megamenu',
265 | ]
266 | );
267 |
268 | $id = $categorySetup->getAttributeGroupId($entityTypeId, $attributeSetId, 'Megamenu');
269 |
270 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_menu_type',30);
271 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_static_width',31);
272 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_category_label',32);
273 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_category_thumbnail_image',33);
274 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_display_top_block',34);
275 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_top_block_id',35);
276 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_top_block_content',36);
277 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_display_left_block',37);
278 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_left_block_id',38);
279 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_left_block_content',39);
280 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_left_block_width',40);
281 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_display_right_block',41);
282 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_right_block_id',42);
283 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_right_block_content',43);
284 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_right_block_width',44);
285 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_display_bottom_block',45);
286 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_bottom_block_id',46);
287 | $categorySetup->addAttributeToGroup($entityTypeId,$attributeSetId,$id,'mega_bottom_block_content',47);
288 |
289 | $installer->endSetup();
290 | }
291 | }
--------------------------------------------------------------------------------
/Model/Category/DataProvider.php:
--------------------------------------------------------------------------------
1 | 'frontend_input',
40 | 'visible' => 'is_visible',
41 | 'required' => 'is_required',
42 | 'label' => 'frontend_label',
43 | 'sortOrder' => 'sort_order',
44 | 'notice' => 'note',
45 | 'default' => 'default_value',
46 | 'size' => 'multiline_count',
47 | ];
48 |
49 | /**
50 | * Form element mapping
51 | *
52 | * @var array
53 | */
54 | protected $formElement = [
55 | 'text' => 'input',
56 | 'boolean' => 'checkbox',
57 | ];
58 |
59 | /**
60 | * Elements with use config setting
61 | *
62 | * @var array
63 | */
64 | protected $elementsWithUseConfigSetting = [
65 | 'available_sort_by',
66 | 'default_sort_by',
67 | 'filter_price_range',
68 | ];
69 |
70 | /**
71 | * List of fields that should not be added into the form
72 | *
73 | * @var array
74 | */
75 | protected $ignoreFields = [
76 | 'products_position',
77 | 'position'
78 | ];
79 |
80 | /**
81 | * @var EavValidationRules
82 | */
83 | protected $eavValidationRules;
84 |
85 | /**
86 | * @var \Magento\Framework\Registry
87 | */
88 | protected $registry;
89 |
90 | /**
91 | * @var \Magento\Framework\App\RequestInterface
92 | */
93 | protected $request;
94 |
95 | /**
96 | * @var Config
97 | */
98 | private $eavConfig;
99 |
100 | /**
101 | * @var StoreManagerInterface
102 | */
103 | private $storeManager;
104 |
105 | /**
106 | * @var CategoryFactory
107 | */
108 | private $categoryFactory;
109 |
110 | /**
111 | * DataProvider constructor
112 | *
113 | * @param string $name
114 | * @param string $primaryFieldName
115 | * @param string $requestFieldName
116 | * @param EavValidationRules $eavValidationRules
117 | * @param CategoryCollectionFactory $categoryCollectionFactory
118 | * @param StoreManagerInterface $storeManager
119 | * @param \Magento\Framework\Registry $registry
120 | * @param Config $eavConfig
121 | * @param \Magento\Framework\App\RequestInterface $request
122 | * @param CategoryFactory $categoryFactory
123 | * @param array $meta
124 | * @param array $data
125 | * @SuppressWarnings(PHPMD.ExcessiveParameterList)
126 | */
127 | public function __construct(
128 | $name,
129 | $primaryFieldName,
130 | $requestFieldName,
131 | EavValidationRules $eavValidationRules,
132 | CategoryCollectionFactory $categoryCollectionFactory,
133 | StoreManagerInterface $storeManager,
134 | \Magento\Framework\Registry $registry,
135 | Config $eavConfig,
136 | \Magento\Framework\App\RequestInterface $request,
137 | CategoryFactory $categoryFactory,
138 | array $meta = [],
139 | array $data = []
140 | ) {
141 | $this->eavValidationRules = $eavValidationRules;
142 | $this->collection = $categoryCollectionFactory->create();
143 | $this->collection->addAttributeToSelect('*');
144 | $this->eavConfig = $eavConfig;
145 | $this->registry = $registry;
146 | $this->storeManager = $storeManager;
147 | $this->request = $request;
148 | $this->categoryFactory = $categoryFactory;
149 | parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
150 | $this->meta = $this->prepareMeta($this->meta);
151 | }
152 |
153 | /**
154 | * Prepare meta data
155 | *
156 | * @param array $meta
157 | * @return array
158 | */
159 | public function prepareMeta($meta)
160 | {
161 | $meta = array_replace_recursive($meta, $this->prepareFieldsMeta(
162 | $this->getFieldsMap(),
163 | $this->getAttributesMeta($this->eavConfig->getEntityType('catalog_category'))
164 | ));
165 |
166 | return $meta;
167 | }
168 |
169 | /**
170 | * Prepare fields meta based on xml declaration of form and fields metadata
171 | *
172 | * @param array $fieldsMap
173 | * @param array $fieldsMeta
174 | * @return array
175 | */
176 | private function prepareFieldsMeta($fieldsMap, $fieldsMeta)
177 | {
178 | $result = [];
179 | foreach ($fieldsMap as $fieldSet => $fields) {
180 | foreach ($fields as $field) {
181 | if (isset($fieldsMeta[$field])) {
182 | $result[$fieldSet]['children'][$field]['arguments']['data']['config'] = $fieldsMeta[$field];
183 | }
184 | }
185 | }
186 | return $result;
187 | }
188 |
189 | /**
190 | * Get data
191 | *
192 | * @return array
193 | */
194 | public function getData()
195 | {
196 | if (isset($this->loadedData)) {
197 | return $this->loadedData;
198 | }
199 | $category = $this->getCurrentCategory();
200 | if ($category) {
201 | $categoryData = $category->getData();
202 | $categoryData = $this->addUseDefaultSettings($category, $categoryData);
203 | $categoryData = $this->addUseConfigSettings($categoryData);
204 | $categoryData = $this->filterFields($categoryData);
205 | if (isset($categoryData['image'])) {
206 | unset($categoryData['image']);
207 | $categoryData['image'][0]['name'] = $category->getData('image');
208 | $categoryData['image'][0]['url'] = $category->getImageUrl();
209 | }
210 | $this->loadedData[$category->getId()] = $categoryData;
211 | }
212 | return $this->loadedData;
213 | }
214 |
215 | /**
216 | * Get attributes meta
217 | *
218 | * @param Type $entityType
219 | * @return array
220 | * @throws \Magento\Framework\Exception\LocalizedException
221 | * @SuppressWarnings(PHPMD.NPathComplexity)
222 | * @SuppressWarnings(PHPMD.CyclomaticComplexity)
223 | */
224 | public function getAttributesMeta(Type $entityType)
225 | {
226 | $meta = [];
227 | $attributes = $entityType->getAttributeCollection();
228 | /* @var EavAttribute $attribute */
229 | foreach ($attributes as $attribute) {
230 | $code = $attribute->getAttributeCode();
231 | // use getDataUsingMethod, since some getters are defined and apply additional processing of returning value
232 | foreach ($this->metaProperties as $metaName => $origName) {
233 | $value = $attribute->getDataUsingMethod($origName);
234 | $meta[$code][$metaName] = $value;
235 | if ('frontend_input' === $origName) {
236 | $meta[$code]['formElement'] = isset($this->formElement[$value])
237 | ? $this->formElement[$value]
238 | : $value;
239 | }
240 | if ($attribute->usesSource()) {
241 | $meta[$code]['options'] = $attribute->getSource()->getAllOptions();
242 | }
243 | }
244 |
245 | $rules = $this->eavValidationRules->build($attribute, $meta[$code]);
246 | if (!empty($rules)) {
247 | $meta[$code]['validation'] = $rules;
248 | }
249 |
250 | $meta[$code]['scopeLabel'] = $this->getScopeLabel($attribute);
251 | $meta[$code]['componentType'] = Field::NAME;
252 | }
253 |
254 | $result = [];
255 | foreach ($meta as $key => $item) {
256 | $result[$key] = $item;
257 | $result[$key]['sortOrder'] = 0;
258 | }
259 |
260 | $result = $this->getDefaultMetaData($result);
261 |
262 | return $result;
263 | }
264 |
265 | /**
266 | * Add use config settings
267 | *
268 | * @param array $categoryData
269 | * @return array
270 | */
271 | protected function addUseConfigSettings($categoryData)
272 | {
273 | foreach ($this->elementsWithUseConfigSetting as $elementsWithUseConfigSetting) {
274 | if (!isset($categoryData['use_config'][$elementsWithUseConfigSetting])) {
275 | if (!isset($categoryData[$elementsWithUseConfigSetting]) ||
276 | ($categoryData[$elementsWithUseConfigSetting] == '')
277 | ) {
278 | $categoryData['use_config'][$elementsWithUseConfigSetting] = true;
279 | } else {
280 | $categoryData['use_config'][$elementsWithUseConfigSetting] = false;
281 | }
282 | }
283 | }
284 | return $categoryData;
285 | }
286 |
287 | /**
288 | * Add use default settings
289 | *
290 | * @param \Magento\Catalog\Model\Category $category
291 | * @param array $categoryData
292 | * @return array
293 | */
294 | protected function addUseDefaultSettings($category, $categoryData)
295 | {
296 | if ($category->getExistsStoreValueFlag('url_key') ||
297 | $category->getStoreId() === Store::DEFAULT_STORE_ID
298 | ) {
299 | $categoryData['use_default']['url_key'] = false;
300 | } else {
301 | $categoryData['use_default']['url_key'] = true;
302 | }
303 |
304 | return $categoryData;
305 | }
306 |
307 | /**
308 | * Get current category
309 | *
310 | * @return Category
311 | * @throws NoSuchEntityException
312 | */
313 | public function getCurrentCategory()
314 | {
315 | $category = $this->registry->registry('category');
316 | if ($category) {
317 | return $category;
318 | }
319 | $requestId = $this->request->getParam($this->requestFieldName);
320 | $requestScope = $this->request->getParam($this->requestScopeFieldName, Store::DEFAULT_STORE_ID);
321 | if ($requestId) {
322 | $category = $this->categoryFactory->create();
323 | $category->setStoreId($requestScope);
324 | $category->load($requestId);
325 | if (!$category->getId()) {
326 | throw NoSuchEntityException::singleField('id', $requestId);
327 | }
328 | }
329 | return $category;
330 | }
331 |
332 | /**
333 | * Retrieve label of attribute scope
334 | *
335 | * GLOBAL | WEBSITE | STORE
336 | *
337 | * @param EavAttribute $attribute
338 | * @return string
339 | */
340 | public function getScopeLabel(EavAttribute $attribute)
341 | {
342 | $html = '';
343 | if (!$attribute || $this->storeManager->isSingleStoreMode()
344 | || $attribute->getFrontendInput() === AttributeInterface::FRONTEND_INPUT
345 | ) {
346 | return $html;
347 | }
348 | if ($attribute->isScopeGlobal()) {
349 | $html .= __('[GLOBAL]');
350 | } elseif ($attribute->isScopeWebsite()) {
351 | $html .= __('[WEBSITE]');
352 | } elseif ($attribute->isScopeStore()) {
353 | $html .= __('[STORE VIEW]');
354 | }
355 |
356 | return $html;
357 | }
358 |
359 | /**
360 | * Filter fields
361 | *
362 | * @param array $categoryData
363 | * @return array
364 | */
365 | protected function filterFields($categoryData)
366 | {
367 | return array_diff_key($categoryData, array_flip($this->ignoreFields));
368 | }
369 |
370 | /**
371 | * Category's fields default values
372 | *
373 | * @param array $result
374 | * @return array
375 | */
376 | public function getDefaultMetaData($result)
377 | {
378 | $result['parent']['default'] = (int)$this->request->getParam('parent');
379 | $result['use_config.available_sort_by']['default'] = true;
380 | $result['use_config.default_sort_by']['default'] = true;
381 | $result['use_config.filter_price_range']['default'] = true;
382 | if ($this->request->getParam('store') && $this->request->getParam('id')) {
383 | $result['use_default.url_key']['checked'] = true;
384 | $result['use_default.url_key']['default'] = true;
385 | $result['use_default.url_key']['visible'] = true;
386 | } else {
387 | $result['use_default.url_key']['checked'] = false;
388 | $result['use_default.url_key']['default'] = false;
389 | $result['use_default.url_key']['visible'] = false;
390 | }
391 |
392 | return $result;
393 | }
394 |
395 | /**
396 | * @return array
397 | */
398 | protected function getFieldsMap()
399 | {
400 | return [
401 | 'general' =>
402 | [
403 | 'parent',
404 | 'path',
405 | 'is_active',
406 | 'include_in_menu',
407 | 'name',
408 | ],
409 | 'megamenu' =>
410 | [
411 | 'mega_menu_type',
412 | 'mega_menu_width',
413 | 'mega_category_label',
414 | 'mega_category_thumbnail_image',
415 | 'mega_display_top_block',
416 | 'mega_top_block_id',
417 | 'mega_top_block_content',
418 | 'mega_display_left_block',
419 | 'mega_left_block_id',
420 | 'mega_left_block_content',
421 | 'mega_left_block_width',
422 | 'mega_display_right_block',
423 | 'mega_right_block_id',
424 | 'mega_right_block_content',
425 | 'mega_right_block_width',
426 | 'mega_display_bottom_block',
427 | 'mega_bottom_block_id',
428 | 'mega_bottom_block_content',
429 | ],
430 | 'content' =>
431 | [
432 | 'image',
433 | 'description',
434 | 'landing_page',
435 | ],
436 | 'display_settings' =>
437 | [
438 | 'display_mode',
439 | 'is_anchor',
440 | 'available_sort_by',
441 | 'use_config.available_sort_by',
442 | 'default_sort_by',
443 | 'use_config.default_sort_by',
444 | 'filter_price_range',
445 | 'use_config.filter_price_range',
446 | ],
447 | 'search_engine_optimization' =>
448 | [
449 | 'url_key',
450 | 'url_key_create_redirect',
451 | 'use_default.url_key',
452 | 'url_key_group',
453 | 'meta_title',
454 | 'meta_keywords',
455 | 'meta_description',
456 | ],
457 | 'assign_products' =>
458 | [
459 | ],
460 | 'design' =>
461 | [
462 | 'custom_use_parent_settings',
463 | 'custom_apply_to_products',
464 | 'custom_design',
465 | 'page_layout',
466 | 'custom_layout_update',
467 | ],
468 | 'schedule_design_update' =>
469 | [
470 | 'custom_design_from',
471 | 'custom_design_to',
472 | ],
473 | 'category_view_optimization' =>
474 | [
475 | ],
476 | 'category_permissions' =>
477 | [
478 | ],
479 | ];
480 | }
481 | }
--------------------------------------------------------------------------------
/Block/Html/Topmega.php:
--------------------------------------------------------------------------------
1 | categoryFactory = $categoryFactory;
103 | $this->_filterProvider = $filterProvider;
104 | $this->_storeManager = $storeManager;
105 | $this->_blockFactory = $blockFactory;
106 | $this->coreRegistry = $registry;
107 | $this->dataHelper = $dataHelper;
108 | $this->_menu = $nodeFactory->create(
109 | [
110 | 'data' => [],
111 | 'idField' => 'root',
112 | 'tree' => $treeFactory->create()
113 | ]
114 | );
115 | $this->categoryHelper = $categoryHelper;
116 | $this->extraClass = '';
117 | $this->menuType = 'default';
118 | $this->storeManager = $storeManager;
119 | $this->currentStore = $this->storeManager->getStore();
120 | $this->mediaUrl = $this->currentStore->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
121 | $this->categoryMediaUrl = $this->mediaUrl."catalog/category/";
122 | $this->parentId = false;
123 | }
124 |
125 | /**
126 | * Get top menu html
127 | *
128 | * @param string $outermostClass
129 | * @param string $childrenWrapClass
130 | * @param int $limit
131 | * @return string
132 | */
133 | public function getHtml2($outermostClass = '', $childrenWrapClass = '', $limit = 0)
134 | {
135 | $this->_eventManager->dispatch(
136 | 'page_block_html_topmenu_gethtml_before',
137 | ['menu' => $this->_menu, 'block' => $this]
138 | );
139 |
140 | $this->_menu->setOutermostClass($outermostClass);
141 | $this->_menu->setChildrenWrapClass($childrenWrapClass);
142 |
143 | $html = $this->_getHtml2($this->_menu, $childrenWrapClass, $limit);
144 |
145 | $transportObject = new \Magento\Framework\DataObject(['html' => $html]);
146 | $this->_eventManager->dispatch(
147 | 'page_block_html_topmenu_gethtml_after',
148 | ['menu' => $this->_menu, 'transportObject' => $transportObject]
149 | );
150 | $html = $transportObject->getHtml();
151 |
152 | return $html;
153 | }
154 |
155 | /**
156 | * Count All Subnavigation Items
157 | *
158 | * @param \Magento\Backend\Model\Menu $items
159 | * @return int
160 | */
161 | protected function _countItems($items)
162 | {
163 | $total = $items->count();
164 | foreach ($items as $item) {
165 | /** @var $item \Magento\Backend\Model\Menu\Item */
166 | if ($item->hasChildren()) {
167 | $total += $this->_countItems($item->getChildren());
168 | }
169 | }
170 | return $total;
171 | }
172 |
173 | /**
174 | * Add sub menu HTML code for current menu item
175 | *
176 | * @param \Magento\Framework\Data\Tree\Node $child
177 | * @param string $childLevel
178 | * @param string $childrenWrapClass
179 | * @param int $limit
180 | * @return string HTML code
181 | */
182 | protected function _addSubMenu2($child, $childLevel, $childrenWrapClass, $limit)
183 | {
184 | $html = '';
185 |
186 | /*if (!$child->hasChildren()) {
187 | return $html;
188 | }*/
189 |
190 | $colStops = null;
191 | if ($childLevel == 0 && $limit) {
192 | $colStops = $this->_columnBrake($child->getChildren(), $limit);
193 | }
194 |
195 | $callParentSubmenu = true;
196 | $menuWidth = ($this->category->getMegaMenuWidth()) ? $this->category->getMegaMenuWidth() : '';
197 | $html .= '';
291 | if($callParentSubmenu)
292 | return $this->_addSubMenu($child, $childLevel, $childrenWrapClass, $limit);
293 |
294 | return $html;
295 | }
296 |
297 | protected function _getHtml(\Magento\Framework\Data\Tree\Node $menuTree,$childrenWrapClass,$limit,$colBrakes = [])
298 | {
299 | $html = '';
300 |
301 | $children = $menuTree->getChildren();
302 | $parentLevel = $menuTree->getLevel();
303 | $childLevel = $parentLevel === null ? 0 : $parentLevel + 1;
304 |
305 | $counter = 1;
306 | $itemPosition = 1;
307 | $childrenCount = $children->count();
308 |
309 | $parentPositionClass = $menuTree->getPositionClass();
310 | $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
311 |
312 | foreach ($children as $child) {
313 | $child->setLevel($childLevel);
314 | $child->setIsFirst($counter == 1);
315 | $child->setIsLast($counter == $childrenCount);
316 | $child->setPositionClass($itemPositionClassPrefix . $counter);
317 |
318 | $outermostClassCode = '';
319 | $outermostClass = $menuTree->getOutermostClass();
320 |
321 | if ($childLevel == 0 && $outermostClass) {
322 | $outermostClassCode = ' class="' . $outermostClass . '" ';
323 | $child->setClass($outermostClass);
324 | }
325 |
326 | if (count($colBrakes) && $colBrakes[$counter]['colbrake']) {
327 | $html .= '';
328 | }
329 |
330 | list($first,$second,$id) = explode('-', $child->getId());
331 | $child['class'] .= ' category_id_'.$id;
332 |
333 | $html .= '_getRenderedMenuItemAttributes($child) . '>';
334 | $html .= '' . $this->escapeHtml(
335 | $child->getName()
336 | ) . ' ';
337 |
338 | if($parentLevel==0 && $menuTree->getId())
339 | {
340 | $this->parentId = substr($menuTree->getId(), strrpos($menuTree->getId(), '-') + 1);
341 | }
342 | if($this->parentId && $this->category && $this->category->getMegaDisplayLeftBlock()!='no' && $this->category->getMegaDisplayLeftBlock()!=null && $this->category->getMegaDisplayLeftBlock()=='sub_expanded_with_image')
343 | {
344 | list($first,$second,$id) = explode('-', $child->getId());
345 | $cat = $this->categoryFactory->create();
346 | if($cat->load($id))
347 | {
348 | if($cat->getMegaCategoryThumbnailImage() && $child->getLevel()>0)
349 | $html .= ' ';
350 | }
351 | }
352 |
353 | $html .= ' ' . $this->_addSubMenu(
354 | $child,
355 | $childLevel,
356 | $childrenWrapClass,
357 | $limit
358 | ) . ' ';
359 | $itemPosition++;
360 | $counter++;
361 | }
362 |
363 | if (count($colBrakes) && $limit) {
364 | $html = ' ';
365 | }
366 |
367 | return $html;
368 | }
369 |
370 | protected function _getHtml2(\Magento\Framework\Data\Tree\Node $menuTree,$childrenWrapClass,$limit,$colBrakes = [])
371 | {
372 | $data_mage_init = 'data-mage-init=\'{"menu":{"responsive":true, "expanded":true, "position":{"my":"left top","at":"left bottom"}}}\'';
373 | $html = '';
374 |
375 | $children = $menuTree->getChildren();
376 | $parentLevel = $menuTree->getLevel();
377 | $childLevel = $parentLevel === null ? 0 : $parentLevel + 1;
378 |
379 | $counter = 1;
380 | $itemPosition = 1;
381 | $childrenCount = $children->count();
382 |
383 | $parentPositionClass = $menuTree->getPositionClass();
384 | $itemPositionClassPrefix = $parentPositionClass ? $parentPositionClass . '-' : 'nav-';
385 |
386 | foreach ($children as $child) {
387 | $child->setLevel($childLevel);
388 | $child->setIsFirst($counter == 1);
389 | $child->setIsLast($counter == $childrenCount);
390 | $child->setPositionClass($itemPositionClassPrefix . $counter);
391 |
392 | $outermostClassCode = '';
393 | $outermostClass = $menuTree->getOutermostClass();
394 |
395 | if ($childLevel == 0 && $outermostClass) {
396 | $outermostClassCode = ' class="' . $outermostClass . '" ';
397 | $child->setClass($outermostClass);
398 | }
399 |
400 | if (count($colBrakes) && $colBrakes[$counter]['colbrake']) {
401 | $html .= ' ';
402 | }
403 |
404 | $catLabelHtml = '';
405 | $this->category = null;
406 | if ($childLevel == 0)
407 | {
408 | $arrayId = explode('-',$child->_getData('id'));
409 | if(isset($arrayId[2]))
410 | {
411 | $id = $arrayId[2];
412 | $this->category = $this->categoryFactory->create();
413 | $this->category->load($id);
414 | $this->coreRegistry->unregister('current_categry_top_level');
415 | $this->coreRegistry->register('current_categry_top_level',$this->category);
416 |
417 | $this->menuType = ($this->category->getMegaMenuType()) ? $this->category->getMegaMenuType() : 'default';
418 |
419 | if($this->menuType=='mega')
420 | {
421 | if($catLabel=$this->category->getMegaCategoryLabel())
422 | {
423 | $this->extraClass .= ' '.strtolower($catLabel);
424 | $catLabelHtml = ''.$this->escapeHtml($this->dataHelper->getCatLabel($catLabel)).' ';
425 | }
426 | $this->extraClass .= ' '.$this->menuType;
427 | }
428 | }
429 | }
430 |
431 | if($this->menuType=='mega')
432 | {
433 | $html .= '_getRenderedMenuItemAttributes2($child) . '>';
434 | $html .= '' . $this->escapeHtml(
435 | $child->getName()
436 | ) .$catLabelHtml. ' ' . $this->_addSubMenu2(
437 | $child,
438 | $childLevel,
439 | $childrenWrapClass,
440 | $limit
441 | ) . ' ';
442 | }
443 | else
444 | {
445 | $html .= '_getRenderedMenuItemAttributes($child) . '>';
446 | $html .= '' . $this->escapeHtml(
447 | $child->getName()
448 | ) .$catLabelHtml. ' ' . $this->_addSubMenu(
449 | $child,
450 | $childLevel,
451 | $childrenWrapClass,
452 | $limit
453 | ) . ' ';
454 | }
455 | $itemPosition++;
456 | $counter++;
457 | }
458 |
459 | if (count($colBrakes) && $limit) {
460 | $html = ' ';
461 | }
462 |
463 | $html .= ' ';
464 |
465 | return $html;
466 | }
467 |
468 | /**
469 | * Generates string with all attributes that should be present in menu item element
470 | *
471 | * @param \Magento\Framework\Data\Tree\Node $item
472 | * @return string
473 | */
474 | protected function _getRenderedMenuItemAttributes2(\Magento\Framework\Data\Tree\Node $item)
475 | {
476 | $html = '';
477 | $attributes = $this->_getMenuItemAttributes($item);
478 | foreach ($attributes as $attributeName => $attributeValue) {
479 | $html .= ' ' . $attributeName . '="' . str_replace('"', '\"', $attributeValue) .$this->extraClass. '"';
480 | }
481 | return $html;
482 | }
483 |
484 | /**
485 | * Returns array of menu item's attributes
486 | *
487 | * @param \Magento\Framework\Data\Tree\Node $item
488 | * @return array
489 | */
490 | protected function _getMenuItemAttributes(\Magento\Framework\Data\Tree\Node $item)
491 | {
492 | $menuItemClasses = $this->_getMenuItemClasses($item);
493 | return ['class' => implode(' ', $menuItemClasses)];
494 | }
495 |
496 | /**
497 | * Returns array of menu item's classes
498 | *
499 | * @param \Magento\Framework\Data\Tree\Node $item
500 | * @return array
501 | */
502 | protected function _getMenuItemClasses(\Magento\Framework\Data\Tree\Node $item)
503 | {
504 | $classes = [];
505 |
506 | $classes[] = 'level' . $item->getLevel();
507 | $classes[] = $item->getPositionClass();
508 |
509 | if ($item->getIsFirst()) {
510 | $classes[] = 'first';
511 | }
512 |
513 | if ($item->getIsActive()) {
514 | $classes[] = 'active';
515 | } elseif ($item->getHasActive()) {
516 | $classes[] = 'has-active';
517 | }
518 |
519 | if ($item->getIsLast()) {
520 | $classes[] = 'last';
521 | }
522 |
523 | if ($item->getClass()) {
524 | $classes[] = $item->getClass();
525 | }
526 |
527 | if ($item->hasChildren()) {
528 | $classes[] = 'parent';
529 | }
530 |
531 | return $classes;
532 | }
533 | public function allowExtension()
534 | {
535 | return $this->dataHelper->allowExtension();
536 | }
537 | /**
538 | * Prepare Content HTML
539 | *
540 | * @return string
541 | */
542 | public function getBlockHtml($id)
543 | {
544 | $blockId = $id;
545 | $html = '';
546 | if ($blockId)
547 | {
548 | $storeId = $this->_storeManager->getStore()->getId();
549 | /** @var \Magento\Cms\Model\Block $block */
550 | $block = $this->_blockFactory->create();
551 | $block->setStoreId($storeId)->load($blockId);
552 | if ($block->isActive()) {
553 | $html = $this->_filterProvider->getBlockFilter()->setStoreId($storeId)->filter($block->getContent());
554 | }
555 | }
556 | return $html;
557 | }
558 | }
559 |
--------------------------------------------------------------------------------
/view/adminhtml/ui_component/category_form.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------