1

I'm creating a site which has a products section.

I have created an entries section called 'Products'.

I have set up some categories, i.e. 'Category One, 'Category Two', 'Category Three'

I have also created a related entries field so I can related products to each other.

When the client adds a new product in 'Category One', they should only be able to relate entries that are in 'Category Two' or 'Category Three'.

Is there a way that I can restrict the results returned in an entries field in the Control Panel to a specific category?

1

There is no native functionality for this at the current time.

You could write a plugin to extend the Products field-type (which itself extends the base entries field-type) - to provide this filter functionality. That is you'd add a categories chooser to the field type and then filter the available products using that category in your plugin.

https://pluginfactory.io would get you started on the plugin scaffolding, and I'd look at /craft/plugins/commerce/fieldtypes/Commerce_ProductsFieldType.php and the native Craft categories field type to get started.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.