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

How can disable the Pimcore Bundle?

To disable the pimcore bundle run the below command on the ubuntu terminal in the …

Leave a Reply

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