-
Notifications
You must be signed in to change notification settings - Fork 315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(chore): make post SyncManager extendable #2196
(chore): make post SyncManager extendable #2196
Conversation
Hi @edwinsiebel, Do you mind sharing with us what is your use case? Although we have that |
Hi @felipeelia, Our use case is to use the Indexable concept per post type; this so the mapping per post type can be different, and the data we push to ES per post type can be managed (customized). I really like the idea of Indexables, but the problem as now is that you need to have a custom SyncManager together with the Custom Indexable. The custom indexable is fine, great even. The custom sync manager would we overkill, as the defaults for Post SyncManager are fine for cpts as well. I hope I explained my use case with clarity. |
If I get the overall idea right @edwinsiebel once you have an indexable for your CPT, will you make use of the EP filters to query the specific path for the CPT indexable based on the query args post type? Won't you have mixed results if you happen to have a query with all post types? |
hi @oscarssanchez , True, that might happen. However, I presume you're working more towards Indexables per (custom) post type or a group of (custom) post types, right? In the future, it might a nice change to have a 'post' and a 'page' indexable as default, and have the possibility to add more (custom) indexables. However, my change does not change the way ElasticPress works, however makes it more extendable, if needed. |
Hi @edwinsiebel , Thanks for the additional information, we have met internally and think this is ok to merge. Would you mind submitting another commit for the linting problems? Thanks! |
Hi @oscarssanchez , I'm trying to do the linting (and fixing), however, I get the following error:
Any idea what I'm doing wrong? |
Hi @edwinsiebel Are you running composer v2 ? It seems this could be the cause. Downgrading for a moment should resolve for now. |
Hi @oscarssanchez , Ah, that was the case. Linting is now 'green'. |
@@ -23,6 +23,8 @@ | |||
*/ | |||
class SyncManager extends SyncManagerAbstract { | |||
|
|||
public $indexable_slug = 'post'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @edwinsiebel can we solve the lint issues detected please https://github.com/10up/ElasticPress/pull/2196/checks?check_run_id=2509586826#step:5:17
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @oscarssanchez , seems this change is outdated (GH also mentions it).
The correct code is: https://github.com/10up/ElasticPress/pull/2196/files#diff-f92959da0a1c85031962be4852910a0972795a92f0a67cdb4f4fd04f9561cd40R32, which is different from the one that you're merging.
Post SyncManager has hardcoded 'post'
In the syncmanager for
post
, the "post type" is hardcode: 'post'. This makes it very hard (almost impossible) to extend the syncmanager when wanting to have a syncmanager for a custom post type.Alternate Designs
The syncmanager in this PR still has the default 'post' posttype, yet is possible to be overridden.
Just create a new CustomPostSyncManager which extends SyncManager (the post syncmanager that is), and set:
Benefits
More DRY, less code.
Possible Drawbacks
None. still the same settings.
Verification Process
All the syncing is still possible, with the same results.
Checklist:
Applicable Issues
None
Changelog Entry
Post SyncManager can now be used for a custom post type.