Closed maxacarvalho closed 4 years ago
Hi @maxacarvalho Could you share the Magento version you are using and the module version?
Also what is the error that you are seeing?
Hi @idobarnoam Let me give you a bit of context.
I have three environments Production, Staging and Development.
The idea is that all three environments share the same Cloudinary account so the resources are always available and up to date across all of them.
The above said. When I was trying to setup the Cloudinary Magento plugin on my local (development environment I got an error saying Incorrect custom transform ...
.
And I was simply inputting the Cloudinary Environment variable.
After some investigation I checked that the class app/code/community/Cloudinary/Cloudinary/Model/System/Config/Free.php
calls a method validateImageUrl($url)
which attempts to get the sampleImage
($this->validateImageUrl($this->sampleImageUrl($transform));
).
For this is a bit weird since the first thing I do when I start a Cloudinary account is to delete the sample image since I don't want things that I'm not using polluting the Media library.
But, since I saw that this weird validation was happening I restored the sample image. Still, the method was calling and returning a 404
saying that the image is not there. But it is there.
The only solution I found was to comment out the line app/code/community/Cloudinary/Cloudinary/Model/System/Config/Free.php:41
, save the configuration and then uncomment the line.
Thanks @maxacarvalho This is very helpful.
Since this might be an issue that was already handled in later versions could you share the version number of both the Cloudinary module you are using and the Magento environment?
Hi again @idobarnoam
The Magento is at version 1.9.3.8
The Cloudinary extension is at version 2.8.2
All patches applied to the Magento code base so you might consider as 1.9.4.0
Thanks, @maxacarvalho would it be possible to update the Cloudinary module to the latest one which is 2.9.6 and see if that helps?
I will do that later today @idobarnoam. It's weird that I'm so many versions behind, I just installed the extension one month ago, downloaded from the Magento market place.
Also, I just downloaded the extension from the releases page and the app/code/community/Cloudinary/Cloudinary/etc/config.xml
file says 2.9.5
instead of 2.9.6
Hi @idobarnoam Just to let you know that the configuration is being saved properly.
But now I have another issue, the method code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php:37
is throwing an exception
There is one error message from magento server
Argument 1 passed to Cloudinary_Cloudinary_Model_Catalog_Product_Media::_getRemovedImages() must be of the type array, null given, called in code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php on line 39
This is happening because the code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php:42
method expects an array but the $product->getMediaGallery()
could return null
I think its safer to test if $product->getData('media_gallery')
returns an array
@maaxxicarvalho Thanks for letting us know.
Is the nodule currently working properly when you get this error?
Hi @idobarnoam
It throws an exception when I try to create or update a product using the Magento API.
The problem happens because the Magento Product media_gallery
can return null
.
Since some of the methods of the Cloudinary plugin expects an array
a fatal error occurs.
For example, the class app/code/community/Cloudinary/Cloudinary/Model/Catalog/Product/Media.php
method newImagesForProduct
That's how it is
public function newImagesForProduct(Mage_Catalog_Model_Product $product)
{
$this->_setNewImages($product->getData('media_gallery'));
return $this->_getNewImages($product);
}
and that's how I solved the issue
public function newImagesForProduct(Mage_Catalog_Model_Product $product)
{
$mediaGallery = $product->getData('media_gallery') ?? [];
$this->_setNewImages($mediaGallery);
return $this->_getNewImages($product);
}
@maaxxicarvalho Thanks for sharing your solution!
I'll take this internally with our dev team and see how we can address the issue internally.
@idobarnoam @maaxxicarvalho Yep, you were right, it might return null and when it does it breaks the configurable product quick create functionality altogether.
Please consider the following PR #49
Closing due to time elapsed.
I notice that when trying to save the configuration or uploading an image the method
\Cloudinary_Cloudinary_Model_System_Config_Free::validateImageUrl
is called.The method above is making a call to the sample image, which returns a 404 and with the method above throws a
throw new Mage_Core_Exception($this->formatError($response));
which makes impossible to save the configuration.