Jump to content

Add tag programmatically


JuliusB

Recommended Posts

Hi folks !

I have a problem. I try to add a tag programmatically with and odd result. Here is the code :

$tag_list[] = "MyTag";
$product = new Product(5003334);    
Tag::addTags($default_lang, $product->id, $tag_list);

I can see the tag on the backoffice on the edit product page BUT I can't found it if I search the tag on the frontoffice.

However if I click the "save" button on the edit product page THEN I can found the product if I search the tag on the frontoffice.

It's like the tag exist but a check or something similar is missing.

I have the same problem if I try to add the tag directly on the DDB.

Please help me ! Thank you !

Link to comment
Share on other sites

Your code looks good but I think there are a Smarty cache on the front, so the product page is not updated until cache clear.

For search problem, maybe it's because the search index is not updated.

So try to clear cache and rebuild search index after create a new tag with your code.

What is your Prestashop version ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...