Troubleshooting Sonata e-commerce: Unable to create product due to missing object types

I’m having trouble setting up a product in Sonata e-commerce. When I try to make a new product, I keep getting an error that says “No object types available”. I’ve looked at the docs and other posts about this, but I’m still stuck.

Here’s what I’ve done so far:

  1. Set up the product.yml file with a bowl manager and type
  2. Added the bowl product to sonata_product.yml
  3. Created an Entity.Product.xml file with the bowl class
  4. Made a Bowl.php class that extends Product
  5. Set up a Product.php abstract class

I’m using Symfony 2.8 and PHP 7.2. My composer.json has all the Sonata bundles installed.

I’ve double-checked everything against the Sonata sandbox on GitHub, but I can’t figure out what I’m missing. Has anyone run into this before? Any ideas on what might be causing the “No object types available” error?

Have you double-checked your service declarations in config.yml? Sometimes the ‘No object types available’ error crops up when the product manager services aren’t properly declared or tagged. Make sure you’ve got something like this:

services:
app.product.bowl:
class: YourNamespace\Product\BowlManager
tags:
- { name: sonata.product.type, alias: bowl, manager: app.product.bowl }

Also, verify that your Bowl entity is correctly registered in doctrine_orm.yml. It should look something like:

doctrine:
orm:
entity_managers:
default:
mappings:
ApplicationSonataProductBundle: ~

If these look good, try running ‘php app/console debug:container | grep product’ to see if your product services are actually being registered. Sometimes the issue is hiding in how Symfony’s loading your configurations.

hey steve89, have u checked if ur product type is registered in the DIC? sometimes that can cause the ‘no object types’ error. also, make sure ur Bowl class is in the right namespace and properly tagged in the service config. if ur still stuck, try runnin ‘php app/console debug:container | grep product’ to see if everything’s registered right. hope this helps!

Hey Steve89, I feel your pain! I had a similar headache when I first tried setting up Sonata e-commerce. Have you checked if your product manager service is correctly registered in your container? Sometimes that sneaky little detail can cause the ‘No object types available’ error.

Also, wild thought, but are you sure your Bowl class is in the right namespace? I once spent hours banging my head against the wall only to realize my namespace was off by one directory.

Oh, and here’s something that might be worth a shot - have you tried running ‘php app/console sonata:easy-extends:generate SonataProductBundle’? Sometimes that can help if the bundle isn’t properly extended.

Let me know if any of these help or if you’re still stuck. We can dig deeper if needed. What other errors are you seeing in your Symfony debug toolbar?