Own Command: Can't edit external image

Hey,
i wrote my own command which works as expected but when I try to set a field from Type “externalImage” which in my opinion should be just another string nothing happens.

I did also look up the function at “var/classes/DataObject/myClass.php” but can’t figgure out what causes my problem.

if you manually set it, you have to give the type Pimcore\Model\DataObject\Data\ExternalImage

1 Like

and how is the syntax? Sorry but I can’t find anything about it in the documentation.

So, this is my simplified execute class of my command for example:

public function execute(InputInterface $input, OutputInterface $output)
    {
        for ($i=0; $i<100; $i++){

            $output->writeln('actual product: '.$i);

            $product = DataObject::getById($i);
            $product->setPictureLink('https://link-to-my-repo.com/image.jpg');
            $product->save();
        }
    }

“PictureLink” in this case would be my Field of type ExternalImage…

In the end this command should take the uploaded external image links and set the prefix of my repo in front of it e.g. like…

public function execute(InputInterface $input, OutputInterface $output)
    {
        for ($i=0; $i<100; $i++){

            $output->writeln('actual product: '.$i);

            $product = DataObject::getById($i);
            $tempVar = $product->getPictureLink;
            $product->setPictureLink('https://link-to-my-repo.com/'.$tempVar);
            $product->save();
        }
    }

Code for that would be:

use Pimcore\Model\DataObject\Data\ExternalImage;

$product->setPictureLink(new ExternalImage('https://link-to-my-repo.com/image.jpg'));
1 Like

Problem solved. Thank you very much !

Oh damn… I got another problem with externalImage. In data-definitions importer i try to import from a csv file a column containing the image filename strings to an externalImage field in Pimcore but the value of each field stays empty while all the other values are beeing set.

@lukashwm I have the same problem importing into externalimage with data-definitions where the field stays empty.

Did you solve it and can you share this?