Inhalte aufrufen

Profilbild

Category product assignment orphin?


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
6 Antworten zu diesem Thema

#1 TripleNico

TripleNico

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 124 Beiträge

Geschrieben: 15 May 2020 - 10:01

Before i remove a product via de WebApi i also remove the assignment of a product in a category by calling DELETE $"{serverBaseUrlOData}Products({ProductID})/ProductCategories({CategoryID})" quickly after calling this endpoint I then delete the product from the OData collection. All goes wel without any error and the product is also deleted. But the category assignment sometimes still remains. When I check the /Product_Category_Mapping table in the database the mapping is really gone. The only fix is by deleting the product in the SQL database itself...



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 15 May 2020 - 11:31

Just a hint... I have never observed a sometimes works, sometimes not, but you can remove all category assignments for a product by sending 0 as related key: Products({ProductID})/ProductCategories(0)

Marcus Gesing

Smartstore AG


#3 TripleNico

TripleNico

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 124 Beiträge

Geschrieben: 15 May 2020 - 11:55

Yeah sometimes sounds vage, to be honest i didn't had much time to track down in which condition this happens. Nevertheless i changed the routine with your tip. This feels like a better way!
 
I also saw that this applies to manufacturers and pictures so i changed that as well. Is it also supported for SpecificationAttributeOptions?
 
Maybe you could describe what the best way is to delete a product via de OData webapi? Or is there a DeleteProduct(ID) function that takes care of all stuff that i'm overlooking? The current way how i deleted OData objects is by removing them from the OData collection by calling: DELETE /odata/v1/Products(id)

 

In addiotion maybe you could add this type of function to the OData metadata and Swagger documentation?



#4 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 15 May 2020 - 12:43

"The current way how i deleted OData objects is by removing them from the OData collection by calling: DELETE /odata/v1/Products(id)"
That's the correct way as it calls the related service method.
 
SpecificationAttributeOptions has no direct product reference. ProductSpecificationAttribute are referenced by products.
Removing would be GET Products.ProductSpecificationAttributes and then DELETE ProductSpecificationAttributes.
 

  • TripleNico gefällt das

Marcus Gesing

Smartstore AG


#5 TripleNico

TripleNico

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 124 Beiträge

Geschrieben: 18 May 2020 - 09:15

Alright so if i just call DELETE /odata/v1/Products(id) then the WebApi service will take care of all the cleanup (Pictures, categories, manufacturers, attributes, specifications, etc...) ??

 

Because if so i will just only call that function when deleting a product



#6 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3801 Beiträge

Geschrieben: 18 May 2020 - 10:53

No, because products are marked as deleted instead of physically removed. Related entities are not touched.

Because if so i will just only call that function when deleting a product

That's ok, because that's exactly what happens when a product is deleted in backend.


  • TripleNico gefällt das

Marcus Gesing

Smartstore AG


#7 TripleNico

TripleNico

    Advanced Member

  • Members
  • PunktPunktPunkt
  • 124 Beiträge

Geschrieben: 18 May 2020 - 12:08

Thanks for the info! :-)