public function saveCategories() { $store = $this->getStore(); if ('nochange' != $this->request->get('categories')) { $store->deleteRelatedRecordSet('ClonedStoreCategory'); foreach (explode(',', $this->request->get('categories')) as $cat) { ClonedStoreCategory::getNewInstance(Category::getInstanceByID($cat), $store)->save(); } } return new JSONResponse(null, 'success', 'Store category settings saved successfully'); }
public function testProductSyncMatchingProductExtraCat() { for ($k = 0; $k <= 1; $k++) { $product = Product::getNewInstance($this->categories['1.2.1']); $product->sku->set($k); $product->save(); } ClonedStoreCategory::getNewInstance($this->categories['1.2.2'], $this->stores[0])->save(); ProductCategory::getNewInstance($product, $this->categories['1.2.1'])->save(); $updater = $this->getUpdater(); $updater->syncAll(); $this->assertRecordCount('Product', 1); }