{"id":1357,"date":"2016-05-19T20:30:51","date_gmt":"2016-05-19T14:30:51","guid":{"rendered":"http:\/\/promincproductions.com\/blog\/?p=1357"},"modified":"2021-10-23T13:52:14","modified_gmt":"2021-10-23T18:52:14","slug":"configuration-dropdown-bug-magento-enterprise-and-amasty-shipping-restrictions","status":"publish","type":"post","link":"https:\/\/promincproductions.com\/blog\/configuration-dropdown-bug-magento-enterprise-and-amasty-shipping-restrictions\/","title":{"rendered":"Magento 1: Configuration Dropdown Bug &#8211; Magento Enterprise and Amasty Shipping Restrictions"},"content":{"rendered":"<p>I came across this issue, which admittedly may have a small affect for Magento installations, but it&#8217;s something that was reported by a team member and bugged me that I couldn&#8217;t find the answer. &nbsp;Well at first &#8211; I figured it out.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Magento-EE-Amasty-Shipping-Restrictions-Bug.jpg\" rel=\"attachment wp-att-367\" data-lasso-id=\"605\" data-rel=\"lightbox-gallery-VSjDgNBL\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"500\" height=\"500\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Magento-EE-Amasty-Shipping-Restrictions-Bug-500x500.jpg\" alt=\"Conflicts with the Enterprise Customer Segment module prevents all of the intended options from displaying in the configuration dropdown.\" class=\"wp-image-1367\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Magento-EE-Amasty-Shipping-Restrictions-Bug-500x500.jpg 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Magento-EE-Amasty-Shipping-Restrictions-Bug-150x150.jpg 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Magento-EE-Amasty-Shipping-Restrictions-Bug-768x768.jpg 768w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Magento-EE-Amasty-Shipping-Restrictions-Bug-600x600.jpg 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Magento-EE-Amasty-Shipping-Restrictions-Bug.jpg 944w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption>Conflicts with the Enterprise Customer Segment module prevents all of the intended options from displaying in the configuration dropdown.<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">The Issue<\/h2>\n\n\n\n<p>The <strong>conditions<\/strong> dropdown for rules in the&nbsp;<strong>Amasty Shipping Restrictions<\/strong> configuration&nbsp;does not show all of the options &#8211; it&#8217;s missing the <strong>Customer Attributes<\/strong> sub-menu.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Menu-Option.png\" rel=\"attachment wp-att-370\" data-lasso-id=\"606\" data-rel=\"lightbox-gallery-VSjDgNBL\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"481\" height=\"458\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Menu-Option.png\" alt=\"This bug affects the Amasty Shipping Restrictions extension in Magento Enterprise Edition.\" class=\"wp-image-1370\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Menu-Option.png 481w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Menu-Option-150x143.png 150w\" sizes=\"(max-width: 481px) 100vw, 481px\" \/><\/a><figcaption>This bug affects the Amasty Shipping Restrictions extension in Magento Enterprise Edition.<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Identifying the Issue<\/h2>\n\n\n\n<p>I was patching the Amasty Shipping Restrictions module for the SUPEE-6788 patch on a development server. &nbsp;A coworker was testing setting up a shipping restriction rule and when choosing an option from the dropdown the page would redirect to the dashboard page. &nbsp;The issue here was that I had a bad reference in the module that needed to be updated yet.<\/p>\n\n\n\n<p>Though that was an un-related issue, it made me compare the functionality between the development and production servers and noticed that while I corrected the redirection issue, there were items missing from the menu.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Versions<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/magento.com\/blog\/magento-news\/introducing-enterprise-edition-1142\" target=\"_blank\" rel=\"noopener\" data-lasso-id=\"607\">Magento Enterprise Edition<\/a> version 1.14.2.0\n<ul>\n<li>This bug only exists on Magento Enterprise<\/li>\n<\/ul>\n<\/li><li><a href=\"https:\/\/amasty.com\/shipping-restrictions.html\" target=\"_blank\" rel=\"noopener\" data-lasso-id=\"608\">Amasty Shipping Restrictions<\/a> version 1.1.2\n<ul>\n<li>I do have a copy of the most recent version of the Amasty Shipping Restrictions extension, version 1.1.8, and have verified this bug exists in that codbase as well. &nbsp;For various business reasons I have chosen to manually&nbsp;patch the extension as oppose to upgrade to the most recent version.<\/li>\n<\/ul>\n<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Configuration<\/h2>\n\n\n\n<ul class=\"wp-block-list\"><li class=\"ecxMsoNormal\">Configuration -&gt; Customers -&gt; Customer Configuration -&gt; Customer Segments -&gt; Enable Customer Segment Functionality\n<ul>\n<li class=\"ecxMsoNormal\">Yes<\/li>\n<\/ul>\n<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Customer-Configuration.png\" rel=\"attachment wp-att-372\" data-lasso-id=\"609\" data-rel=\"lightbox-gallery-VSjDgNBL\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"500\" height=\"261\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Customer-Configuration-500x261.png\" alt=\"&quot;Enabling\" class=\"wp-image-1372\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Customer-Configuration-500x261.png 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Customer-Configuration-768x402.png 768w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Customer-Configuration-150x78.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Customer-Configuration-600x314.png 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Customer-Configuration.png 899w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Happening<\/h2>\n\n\n\n<p>By enabling the&nbsp;configuration setting above, the&nbsp;<strong>Customer Segments<\/strong> option is added to the dropdown.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-Missing-Customer-Attributes.png\" rel=\"attachment wp-att-37\" data-lasso-id=\"610\" data-rel=\"lightbox-gallery-VSjDgNBL\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"500\" height=\"299\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-Missing-Customer-Attributes-500x299.png\" alt=\"Customer Segments is an option for the shipping restriction rule configuration\" class=\"wp-image-1371\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-Missing-Customer-Attributes-500x299.png 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-Missing-Customer-Attributes-768x460.png 768w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-Missing-Customer-Attributes-150x90.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-Missing-Customer-Attributes-600x359.png 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-Missing-Customer-Attributes.png 770w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption>Customer Segments is an option for the shipping restriction rule configuration<\/figcaption><\/figure><\/div>\n\n\n\n<p>The Shipping Restrictions module then attempts to add the&nbsp;<strong>Customer Attributes<\/strong> category with it&#8217;s sub-options to the dropdown.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-with-Customer-Attributes.png\" rel=\"attachment wp-att-369\" data-lasso-id=\"611\" data-rel=\"lightbox-gallery-VSjDgNBL\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img decoding=\"async\" width=\"500\" height=\"331\" src=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-with-Customer-Attributes-500x331.png\" alt=\"The customer attributes section should be added to this dropdown as well, however because of this bug it is not displaying like it should.\" class=\"wp-image-1369\" srcset=\"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-with-Customer-Attributes-500x331.png 500w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-with-Customer-Attributes-768x508.png 768w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-with-Customer-Attributes-150x99.png 150w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-with-Customer-Attributes-600x397.png 600w, https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Amasty-Shipping-Restrictions-Dropdown-with-Customer-Attributes.png 772w\" sizes=\"(max-width: 500px) 100vw, 500px\" \/><\/a><figcaption>The customer attributes section should be added to this dropdown as well, however because of this bug it is not displaying like it should.<\/figcaption><\/figure><\/div>\n\n\n\n<p>I say attempts because the bug in the Amasty Shipping Restrictions module prevents this from actually happening.<\/p>\n\n\n\n<p>The <strong>getNewChildSelectOptions()<\/strong> method in:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">app\/code\/local\/Amasty\/Shippingrestrictions\/Model\/Condition\/Combine.php<\/pre>\n\n\n\n<p>Will combine the already defined dropdown options with the&nbsp;<strong>Customer Attribute<\/strong> submenu options that are available to the&nbsp;Amasty Shipping Restrictions module. &nbsp;This is an overridden method originally defined in:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">app\/code\/core\/Mage\/Rule\/Model\/Condition\/Combine.php<\/pre>\n\n\n\n<p>On line 32<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Mage::dispatchEvent('salesrule_rule_condition_combine', array('additional' =&gt; $additional));<\/code><\/pre>\n\n\n\n<p>will trigger an observer than will actually do the work of combining the dropdown options. &nbsp;This is TRYING to call an observer defined in:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">app\/code\/local\/Amasty\/Shiprestriction\/etc\/config.xml<\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;salesrule_rule_condition_combine&gt;\n    &lt;observers&gt;\n        &lt;amasty_shiprestriction_model_observer&gt;\n            &lt;type&gt;singleton&lt;\/type&gt;\n            &lt;class&gt;amshiprestriction\/observer&lt;\/class&gt;\n            &lt;method&gt;handleNewConditions&lt;\/method&gt;\n        &lt;\/amasty_shiprestriction_model_observer&gt;\n    &lt;\/observers&gt;\n&lt;\/salesrule_rule_condition_combine&gt;<\/code><\/pre>\n\n\n\n<p>And this is where we finally get to the flaw. &nbsp;The observer, <strong>salesrule_rule_condition_combine<\/strong>, is already defined by the Enterprise Customer Segment module.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">app\/code\/core\/Enterprise\/CustomerSegment\/etc\/config.xml<\/pre>\n\n\n\n<p>Because there are two observers with the same name, only one can get used and the Enterprise module wins. &nbsp;So because the configuration is set to add Customer Segments the Shipping Restrictions module doesn&#8217;t correctly combine it&#8217;s options into the dropdown. &nbsp;However, if you had the Customer Segments option set to no, then the Customer Attributes would show in the dropdown.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Fix for the Bug<\/h2>\n\n\n\n<p>The solution to this bug is simple really &#8211; the name of the observer for the Amasty Shipping Restrictions extension needs to be changed to not conflict with the Enterprise module.<\/p>\n\n\n\n<p>This solution will call two observers &#8211; one for the Amasty Shipping Restrictions module to add the&nbsp;<strong>Customer Attributes<\/strong> submenu and then to the Enterprise Customer Segment module which will add the&nbsp;<strong>Customer Segments<\/strong> options.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Change the Observer Name<\/h3>\n\n\n\n<p>File:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">app\/code\/local\/Amasty\/Shiprestriction\/etc\/config.xml<\/pre>\n\n\n\n<p>Change This:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;salesrule_rule_condition_combine&gt;\n    ...\n&lt;\/salesrule_rule_condition_combine&gt;<\/code><\/pre>\n\n\n\n<p>To This:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;amshiprestriction_salesrule_rule_condition_combine&gt;\n    ...\n&lt;\/amshiprestriction_salesrule_rule_condition_combine&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Call the New Observer Name<\/h3>\n\n\n\n<p>File:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">app\/code\/local\/Amasty\/Shippingrestrictions\/Model\/Condition\/Combine.php<\/pre>\n\n\n\n<p>Add this line on line 33:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Mage::dispatchEvent('amshiprestriction_salesrule_rule_condition_combine', array('additional' =&gt; $additional));<\/code><\/pre>\n\n\n\n<p>For clarity sake, this should be added after&nbsp;this line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Mage::dispatchEvent('salesrule_rule_condition_combine', array('additional' =&gt; $additional));<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Clear the Cache<\/h3>\n\n\n\n<p>Because we made a modification to the XML you&#8217;ll need to choose System -&gt; Cache Managmeent and clear the following caches:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Configuration<\/li><li>Layotus<\/li><li>Blocks HTML Output<\/li><\/ul>\n\n\n\n<p>Now, refresh the Amasty Shipping Restrictions rules page and you&#8217;ll see all of the desired options in the dropdown.<\/p>","protected":false},"excerpt":{"rendered":"<p>I came across this issue, which admittedly may have a small affect for Magento installations, but it&#8217;s something [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1367,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[46,5],"tags":[],"class_list":["post-1357","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento","category-website-development"],"jetpack_featured_media_url":"https:\/\/promincproductions.com\/blog\/wp-content\/uploads\/2016\/05\/Magento-EE-Amasty-Shipping-Restrictions-Bug.jpg","jetpack_shortlink":"https:\/\/wp.me\/p4BbcR-lT","jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/1357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/comments?post=1357"}],"version-history":[{"count":13,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/1357\/revisions"}],"predecessor-version":[{"id":2030,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/posts\/1357\/revisions\/2030"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media\/1367"}],"wp:attachment":[{"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/media?parent=1357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/categories?post=1357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/promincproductions.com\/blog\/wp-json\/wp\/v2\/tags?post=1357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}