/**
  * Should be able to set the tag ids for a product.
  */
 public function testSyncProductTagIds()
 {
     /** @var Product|MockObject $product */
     $product = $this->makeMock(Product::class);
     $tagsRelation = $this->makeMock(BelongsToMany::class);
     $product->expects($this->atLeastOnce())->method('tags')->willReturn($tagsRelation);
     $tagIds = [1, 2, 3];
     $tagsRelation->expects($this->atLeastOnce())->method('sync')->with($tagIds);
     $this->tagRepository->syncProductTagIds($product, $tagIds);
 }
Beispiel #2
0
 /**
  * @param Request $request
  * @param string  $sku
  *
  * @throws NotFoundException
  *
  * @return RedirectResponse
  */
 public function putProductTags(Request $request, string $sku)
 {
     $product = $this->productRepository->loadBySku($sku);
     $tagIds = (array) $request->get('tag-ids');
     $this->tagRepository->syncProductTagIds($product, $tagIds);
     $this->webUi->successMessage("Tags updated for `{$product->sku}`");
     return $this->webUi->redirect('products.show', [$product->sku]);
 }