3

I am trying to implement the following: enter image description here

The idea is to be able to filter products by the conditions which allow only product attributes. (I do not want the additional columns in the grid instead). When I click "All" or "TRUE" or green "+" nothing happens. I know this feature involves a lot of deep Magento knowledge which I don't yet posses. For now I am trying to make the code work the dirty way (I am amending core files) for testing purposes. Ideally I need to have an observer or the layout file. The core file I amend to implement the feature is called Tabs.php and is located under app/code/Core/Mage/Adminhtml/Block/Catalog/Category directory. The particular function is called _prepareLayout() I am trying to inject the created form to the Category Products tab which is represented by the class extending the grid. Since I am adding a new form to the tab alongside the original grid I concluded to amend the Tabs.php file instead of the Grid.php one. Here is the content:

    $model = Mage::getModel('salesrule/rule')->getCollection()->getFirstItem();
    $renderer = Mage::getBlockSingleton('adminhtml/widget_form_renderer_fieldset');
    $text = 'Apply the rule only to cart items matching the following conditions (leave blank for all items)';
    $config = array('legend' => Mage::helper('salesrule')->__($text));
    $fieldset = $form->addFieldset('actions_fieldset', $config)->setRenderer($renderer);
    $fieldset->addField('actions', 'text', array(
        'name' => 'actions',
        'label' => Mage::helper('salesrule')->__('Apply To'),
        'title' => Mage::helper('salesrule')->__('Apply To'),
        'required' => true,
    ))->setRule($model)->setRenderer(Mage::getBlockSingleton('rule/actions'));
    $form->setValues($model->getData());
    $this->addTab('products', array(
        'label'     => Mage::helper('catalog')->__('Category Products'),
        'content'   => $form->toHtml() . $this->getLayout()->createBlock(
            'adminhtml/catalog_category_tab_product',
            'category.product.grid'
        )->toHtml(),
    ));

The original "Shopping Cart Price Rules" is implemented in (there are tons of files really, but the main one is probably in) the Actions.php file located under app/code/core/Mage/Adminhtml/Block/Promo/Quote/Edit/Tab directory. The function is called _prepareForm().

Can you help me by giving a hint on how can I implement that rule block please? Huge thank you in advance!

1
  • This is not a small task. Will require a lot of code blocks and understanding of how the rules system works. At this point i would be so bold as to refer you to my extension that already does this planned functionality, and if i can say so myself, does it very well. :) proxiblue.com.au/premium-modules/…
    – ProxiBlue
    Feb 28 '16 at 1:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.