I have about 1,000 listings created under a vendor name.
I want to update those listings and give them a new vendor name (another username that exists in Hivepress).
What’s the best/easiest way to do this?
I have about 1,000 listings created under a vendor name.
I want to update those listings and give them a new vendor name (another username that exists in Hivepress).
What’s the best/easiest way to do this?
Hi,
You need to select the listings and click Bulk Edit, which will allow you to change the author field. But note that you also need to add a PHP snippet to show this author field:
add_filter(
'hivepress/v1/post_types',
function( $post_types ) {
$post_types['listing']['supports'][] = 'author';
return $post_types;
}
);
I hope this is helpful to you.
Hey Andrii,
Thanks for the quick reply and the helpful solution. That filter lets me bulk edit the author, but I don’t see any way to bulk edit the vendor (see screenshot).
I tried creating a second snippet where I replace ‘author’ with ‘vendor’
I appreciate your help!
Hi,
If you switch the listing author (user), the vendor will automatically switch as well.
That isn’t happening for me, unfortunately. When I switch the listing author, the vendor doesn’t change. Here’s what I see: Bulk Edit Author | Loom
Hi,
If the newly selected user has a vendor, then try to re-save one of the listings after bulk edit (press the update button) and check if the vendor changes.
The opposite happens. If I bulk edit all the authors from “par3nearmedev” to “josh” and then I go and re-save one of the listings, it changes the author back to “par3nearmedev”
The vendor stays at “par3nearmedev” - in both cases, I want to switch these all to “josh”
Hi,
Sorry for the confusion, we reviewed the code in more detail, and the user is secondary and switches by vendor, not vice versa.
We can provide a PHP snippet to make such a change, but please provide more details on what basis the listings are selected, by common vendor or manually. That is, do you need to switch all listings of one vendor to another?
Also, as another option, you can transfer the vendor profile to another user, then do a bulk edit and update the listings (without changing anything); the author will automatically switch (and if you re-save after the user, the vendor profile is synchronized with the current user).
Thanks for reviewing this further.
To answer your first question, yes. I want to change all listings assigned to par3nearmedev to josh
As to the second option you described, if you create a video showing me how to do this, I’m happy to follow your instructions.
Again, thanks for your help.
Just following up on this…
Thanks!
Please try this code snippet:
add_action(
'template_redirect',
function() {
$listings = \HivePress\Models\Listing::query()->filter(
[
'vendor' => 123,
]
)->get();
foreach ( $listings as $listing ) {
$listing->set_vendor( 123 )->save_vendor();
}
}
);
Replace 123 with the IDs of the vendor to switch the listings from / to (you can check these in the URL while you edit the vendor profile in WordPress/Vendors). The snippet will run if you visit the website home page. Afterwords, please remove the snippet, also I recommend bulk editing listings and just re-saving them, this will also switch the corresponding user. In any case, please create a backup of the database before running the snippet.
Hope this helps
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.