Home » PHP » Pimcore » How the data be save in Pimcore 5 Database

How the data be save in Pimcore 5 Database

Pimcore

There is no big deal to save data in the Pimcore Database. The below code snippet is for to check if the data is already available than it will not be save otherwise data will be save. The below code is executed on Pimcore 5.

public function defaultAction(Request $request) {       
        $data = \Pimcore\Model\DataObject\ClassName::getList();
        $data->setCondition("o_key = 'hello-world'");
        $data->load();  
        if( count($data) == 0 && $data->getObjects()[0]->getTitle() != 'Hello World'){
        $newObject->setKey(\Pimcore\File::getValidFilename('Hello World'));       
        $newObject->setParentId(1);
        $newObject->setTitle("Hello World");
        $newObject->setShortDescription("Some Text");
        $newObject->setPublished(true);
        $newObject->setStatus(true);
        $newObject->save();
        }
    }

Check Also

Pimcore

Top Pimcore 5 Interview Questions And Answers

Top Pimcore 5 Interview Questions And Answers Part 1

Leave a Reply

Your email address will not be published. Required fields are marked *