1

i want to add Special Price From Date and Special Price To Date in Enterprise Edition.By default this feature is not available in E.E but available in C.E enter image description here

2 Answers 2

2

Yes you can display those two hidden fields. Many solution elsewhere mention to override the vendor/magento/module-catalog-staging/etc/adminhtml/di.xml. But this solution does not work. I'm mentioning the solution which I applied. The two fields are hidden using the Modifier Pools, so we would have to override those modifiers pool.

  1. override modifier in your Vendor/Module/etc/adminhtml/di.xml

    <virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="eav" xsi:type="array">
                    <item name="class" xsi:type="string">Vendor\Module\Ui\DataProvider\Product\Form\Modifier\Eav</item>
                    <item name="sortOrder" xsi:type="number">10</item>
                </item>
                <item name="advanced-pricing" xsi:type="array">
                    <item name="class" xsi:type="string">catalogProductAdvancedPricingModifierCustom</item>
                    <item name="sortOrder" xsi:type="number">90</item>
                </item>
            </argument>
        </arguments>
    </virtualType>
    
    //And then define the scope for advance pricing form
    <virtualType name="catalogProductAdvancedPricingModifierCustom" type="Vendor\Module\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing">
       <arguments>
          <argument name="scopeName" xsi:type="string">product_form.product_form</argument>
        </arguments>
    </virtualType>
    
  2. Now create the modifier Vendor\Module\Ui\DataProvider\Product\Form\Modifier\Eav and override the parent construct to remove the attributes from $attributesToEliminate array

    namespace Vendor\Module\Ui\DataProvider\Product\Form\Modifier;
    
    use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav as CatalogEav;
    
    class Eav extends CatalogEav
    {
       public function __construct(
         ...
         $attributesToDisable = [],
         $attributesToEliminate = [],
         CompositeConfigProcessor $wysiwygConfigProcessor = null,
         ScopeConfigInterface $scopeConfig = null,
         AttributeCollectionFactory $attributeCollectionFactory = null,
         AuthorizationInterface $auth = null
       ) {
           unset($attributesToEliminate['special_from_date']);
           unset($attributesToEliminate['special_to_date']);
           parent::__construct(
             ...
             $attributesToDisable,
             $attributesToEliminate,
             $wysiwygConfigProcessor,
             $scopeConfig,
             $attributeCollectionFactory,
             $auth
          );
       }
    }
    
  3. In Magento\CatalogStaging\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing file the container_special_from_date and container_special_to_date are unset from meta. so we will now override the modifyMeta function in our module. Vendor\Module\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing

    namespace Vendor\Module\Ui\DataProvider\Product\Form\Modifier;
    
    use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing as CatalogAdvancedPricing;
    
    class AdvancedPricing extends CatalogAdvancedPricing
    {
        public function modifyMeta(array $meta)
        {
           $this->meta = parent::modifyMeta($meta);
           return $this->meta;
        }
    }
    

If you want to display these attributes in catalog staging - schedule update form also. then override the modifier virtual type in the same way.

  • Add you modifier Vendor/Module/etc/adminhtml/di.xml

     <virtualType name="Magento\CatalogStaging\Ui\DataProvider\Product\Form\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool">
          <arguments>
             <argument name="modifiers" xsi:type="array">
                  <item name="eav" xsi:type="array">
                       <item name="class" xsi:type="string">Vendor\Module\Ui\DataProvider\Product\Form\Modifier\CatalogStaging\Eav</item>
                           <item name="sortOrder" xsi:type="number">10</item>
                       </item>
                       <item name="advanced-pricing" xsi:type="array">
                           <item name="class" xsi:type="string">Vendor\Module\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing</item>
                           <item name="sortOrder" xsi:type="number">90</item>
                  </item>
             </argument>
          </arguments>
     </virtualType>
     //And then define the scope for advance pricing form
     <type name="Vendor\Module\Ui\DataProvider\Product\Form\Modifier\AdvancedPricing">
         <arguments>
             <argument name="scopeName" xsi:type="string">catalogstaging_update_form.catalogstaging_update_form</argument>
         </arguments>
     </type>
    
  • Add your eav modifier file to override CatalogStaging Eav modifier - Vendor\Module\Ui\DataProvider\Product\Form\Modifier\CatalogStaging\Eav

     namespace Vendor\Module\Ui\DataProvider\Product\Form\Modifier\CatalogStaging;
    
     use Magento\CatalogStaging\Ui\DataProvider\Product\Form\Modifier\Eav as CatalogEav;
    
     class Eav extends CatalogEav
     {
        public function __construct(
          ...
          $attributesToDisable = [],
          $attributesToEliminate = [],
          CompositeConfigProcessor $wysiwygConfigProcessor = null,
          ScopeConfigInterface $scopeConfig = null,
          AttributeCollectionFactory $attributeCollectionFactory = null,
          AuthorizationInterface $auth = null
        ) {
            unset($attributesToEliminate['special_from_date']);
            unset($attributesToEliminate['special_to_date']);
            parent::__construct(
              ...
              $attributesToDisable,
              $attributesToEliminate,
              $wysiwygConfigProcessor,
              $scopeConfig,
              $attributeCollectionFactory,
              $auth
           );
        }
     }
    
5
  • I have tried this code but it did not work... Can you please share your module so I can try that. Thanks in advance. Commented Dec 16, 2021 at 16:43
  • Sure Pramod. Also it will be helpful if you can share the error you are facing. Commented Dec 17, 2021 at 12:15
  • there was Argument error when I was trying to created Advance Price section. Commented Dec 17, 2021 at 13:33
  • 1
    Thank you @AfreenSheikh, I confirmed that the solution works as expected.
    – Duc To
    Commented Sep 10, 2022 at 18:07
  • Thanks for confirming @DucTo Commented Sep 11, 2022 at 19:10
0

By default this functionality is not available for the EE edition of Magento2, You can check the below URL for more details :

https://github.com/mailchimp/mc-magento2/issues/391

2
  • Yeah i know, but how can i override this feature in Enterprise edition ? And why this feature remove from Enterprise Edition can you Elaborate please . Commented Mar 22, 2019 at 11:00
  • Yes you can do this very easily, create two new date attribute from admin. further create your own helper function and getProductCollection with these two date filter. Commented Mar 22, 2019 at 11:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.