Question: i am trying to update product price when product is added to cart

It works and the price is updated but it does not allow me to add any other product to the cart except the product where condition satisfy

below is my code

**cart.php**

```
use Magento\Framework\Event\ObserverInterface;

/**
 * Class Cart
 * @package VendorName\Changeprice\Observer
 */
class Cart implements ObserverInterface
{
    /**
     * @param \Magento\Framework\Event\Observer $observer
     */
    public function execute(\Magento\Framework\Event\Observer $observer) {

        $item = $observer->getEvent()->getData('quote_item');

        $product = $observer->getEvent()->getData('product');
        if($product->getCustomAttribute('test')->getValue() == 1){
            $price = $product->getCustomAttribute('custom_price')->getValue(); 
        }
        else{
            $price = $product->getFinalPrice();
        }
        $item->setOriginalCustomPrice($price);
        $item->setCustomPrice($price);
        return $this;
    }
}

```

etc/events.xml

```
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="checkout_cart_product_add_after">
        <observer name="vendorname_checkout_cart_product_add_after" instance="Vendor\Module\Observer\Cart"/>
    </event>
</config>

```

Now the problem is, it only allow to add the product when if condition is true

```
if($product->getCustomAttribute('test')->getValue() == 1){
            $price = $product->getCustomAttribute('custom_price')->getValue(); 
        }
else{
            $price = $product->getFinalPrice();
        }

```

Answer: 
You can add a custom indexer to do indexing on the basis of website & store id.

Reference link -

<https://devdocs.magento.com/guides/v2.4/extension-dev-guide/indexing-custom.html>
This is not possible in native Magento.

The only reason I saw so far was because of parallelization - it is possible to set "indexer dimensions" so that price indexing tables are written by customer group or **per website.**

More details in
<https://community.magento.com/t5/Magento-DevBlog/Indexers-parallelization-and-optimization/ba-p/104922>

What specific business requirement are we trying to solve here?