1

I need to share some product and category data (mostly text/textarea fields) between multiple storeviews ...

  • website 1
    • b2c
      • de (use default)
      • en
      • ...
    • b2b
      • en (same data as in "b2c-en" view)
      • ...

Everytime I update i.e. product/category attribute in "b2c-en" it should also be saved/reused in "b2b-en" storeview.

Is there a way to manipulate SQL-query that saves proudct/category data to save it for serveral storeviews? Or any other ideas?

0

Simple solution w/o changing queries ...

  1. add some admin config sections to ...
    • set attrributes to sync
    • map stores
  2. add observers for catalog_category_save_after and catalog_product_save_after
  3. compare getData() and getOrigData() for configured attributes

Sample observer code (maybe someone has better ideas):

# category data
$category = $observer->getCategory();
if ($syncData = /* ... */) {
    foreach ($this->getTargetStoreIds($category->getStoreId()) as $storeId) {
        $category->setStoreId($storeId);
        $category->addData($syncData);
        foreach ($syncData as $attribute => $value) {
            $category->getResource()->saveAttribute($category, $attribute);
        }
    }
}

# product data
$product = $observer->getProduct();
if ($syncData = /* ... */) {
    foreach ($this->getTargetStoreIds($product->getStoreId()) as $storeId) {
        Mage::getSingleton('catalog/product_action')->updateAttributes(
            array($product->getId()),
            $syncData,
            $storeId
        );
    }
}
|improve this answer|||||

Your Answer

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

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