Creating a new collection entry


Can I ask for a bit of advice on how to make a new collection entry for an import script? Ive got the updating side of things working but I keep getting

"call to a member function save() on null" when creating

I've looked at

which just refers to ->etc..... and doesnt give a full example so I've got

        $entry=Entry::findBySlug('product-1', 'products');
        if (!$entry){
            $entry = Entry::make();
            $entry->set("title","product name");

which gives the aforementioned error. I realise as a minimum I'm missing how to tell it that I'm creating a "products" collection entry and what blueprint to use and I assume it will auto create the slug?

Is there more complete documentation I'm missing or can someone point me in the right direction for getting a product created?

Many thanks.


>>>>>>> Unanswered <<<<<<<
2 Replies