0

I have a new attribute called feature (Yes or No), If i set yes it automatically assign one new category called feature.

closed as unclear what you're asking by sv3n, Manashvi Birla, Jai, Piyush, Priyank Oct 30 '18 at 5:39

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

1

I currently don't have time to write the full code for you, but I can point you in the right direction.

What i would do is create a custom module for this. I will create an observer that listens for a event like catalog_product_save_after. See this blog post for example The observer could look like something like this:

public function catalog_product_save_after($observer)
{
    $product = $observer->getProduct();

    if($product->getData('feature') == 1){ //1 for yes, 0 for no
        Mage::getSingleton('catalog/category_api')->assignProduct(111,$p‌​roduct->getId()); //replace 111 with the category id
    }   
}

I have not tested if it works, but it should be something in the right direction. The code can probably be improved, for example by checking if the product already are in the category.

My workflow for this solution was to google for:

  • Event fired when product is saved magento
  • Get product attribute data magento
  • Magento programmatically add product to category
  • You can also use this extension: Dynamic Category Products, with which you can assign products to categories using rules. Basically, you don't have to worry about the product appearing in the categories, as the assignment will be automated, so no further code required. – ProxiBlue Dec 31 '15 at 3:55

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