Reputation: 2437
I'm able to upload assets using PHP API in pimcore using the documentation
$newAsset = new Pimcore\Model\Asset();
$newAsset->setFilename("myAsset.png");
$newAsset->setData(file_get_contents("some-file.png"));
$newAsset->setParent(Pimcore\Model\Asset::getByPath("/"));
$newAsset->save();
What if I want to move that asset from current folder to another using PHP API?
I have tried with the following code, but it didn't worked
$asset1 = Pimcore\Model\Asset::getById(132); // 132 -> asset id
$asset1->setParentId(11); //11 is the id of the folder created in pimcore. Want to move asset to this folder.
$asset1->save();
Upvotes: 0
Views: 1675
Reputation: 83
Try using:
$parent = Pimcore\Model\Asset::getById(11);
$asset->setParent($parent);
$asset->save();
Upvotes: 1