#Sparsh Auto Related Products Module

Magento 2 Auto Related Products is an extension that uses sets of conditions and actions as rules to dynamically showcase related, cross-sell, and up-sell items in your store to help customers easily find necessary products on the product, category, shopping cart, and checkout pages.

##Support: 
version - 2.3.x, 2.4.x

##How to install Extension

1. Download the archive file.
2. Unzip the file
3. Create a folder [Magento_Root]/app/code/Sparsh/AutoRelatedProducts
4. Drop/move the unzipped files to directory '[Magento_Root]/app/code/Sparsh/AutoRelatedProducts'

#Enable Extension:
- php bin/magento module:enable Sparsh_AutoRelatedProducts
- php bin/magento setup:upgrade
- php bin/magento setup:di:compile
- php bin/magento setup:static-content:deploy
- php bin/magento cache:flush

#Disable Extension:
- php bin/magento module:disable Sparsh_AutoRelatedProducts
- php bin/magento setup:upgrade
- php bin/magento setup:di:compile
- php bin/magento setup:static-content:deploy
- php bin/magento cache:flush

## Hyvä theme support

This extension now ships Hyvä-friendly templates. They live at:

```
view/frontend/theme/Hyva/default/templates/auto_related_products_rules.phtml
view/frontend/theme/Hyva/default/templates/auto_related_products_ajax.phtml
```

Magento's module theme-fallback resolves these automatically whenever the
active theme is `Hyva/default` (or any theme that has it as an ancestor) -
no extra install step needed beyond the normal ones above. On any other
theme (Luma, Blank, custom non-Hyvä themes) the original jQuery/Slick
templates in `view/frontend/templates/` are used exactly as before, so the
extension still works unchanged for non-Hyvä stores.

What changed for Hyvä:
- No jQuery, RequireJS, or Slick. The product slider, popup widgets and the
  "ajax" load mode are all rebuilt with plain Alpine.js/vanilla JS.
- Markup uses Tailwind utility classes instead of Luma's `products-grid` /
  `product-item-*` classes.
- Add-to-cart, add-to-wishlist and add-to-compare use `fetch()` and dispatch
  `reload-customer-section-data` afterwards so the mini-cart, wishlist count
  and compare list refresh the same way they do elsewhere in a Hyvä store.
  If your theme exposes `window.dispatchMessages()` (most Hyvä setups do),
  it's used to show the success/error notification.
- Product images, price boxes and review summaries are rendered through the
  normal `getImage()`/`getProductPrice()`/`getReviewsSummaryHtml()` calls, so
  they automatically pick up Hyvä's own image/price/review templates - no
  changes were needed there.

Two things to check on your own project, since they depend on your
theme's exact setup rather than on this extension:

1. **Tailwind content scanning** - Hyvä's `tailwind.config.js` only scans
   the paths listed in its `content` array. Since these templates live in
   this module rather than in your theme package, add this module's Hyvä
   templates to that array so the utility classes used here get compiled,
   e.g.:
   ```js
   content: [
     // ...your existing paths
     '../../vendor/sparsh/module-auto-related-products/view/frontend/theme/Hyva/default/templates/*.phtml',
     // or, if the module lives in app/code:
     '../../app/code/Sparsh/AutoRelatedProducts/view/frontend/theme/Hyva/default/templates/*.phtml',
   ],
   ```
2. **`.btn` / `.btn-primary` classes** - the Add to Cart button uses these
   component classes, matching Hyvä's own default button styling. If your
   theme has renamed or removed them, adjust the class names in
   `auto_related_products_rules.phtml` to match your theme's button
   component.