Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0b877d2
v1.12.0,CLOUDINARY-269: Improved product-gallery-api - now supports b…
May 11, 2020
06d6acf
v1.12.0,CLOUDINARY-269: fixes on ProductGalleryApiQueue process
May 14, 2020
ee6f770
v1.12.0,CLOUDINARY-269: fixes on ProductGalleryApiQueue process
May 14, 2020
e7efe99
v1.12.0,CLOUDINARY-270: Added CSP whitelist
May 14, 2020
8399260
v1.12.0: Change version to 1.12.0
May 17, 2020
9ed2cd6
v1.12.0: Changed CSP to restrict mode
May 17, 2020
e749700
v1.13.0,CLOUDINARY-261: Add support for spinset asset types - step 1
May 17, 2020
ae5dc36
v1.13.0,CLOUDINARY-261: Adding spinset support to PGW
May 20, 2020
86e9cca
v1.13.0,CLOUDINARY-276: Added preg_quote to parseCloudinaryUrl()
May 20, 2020
fabbb93
v1.13.0,CLOUDINARY-261: Adding spinset support to PGW
May 20, 2020
4bc4836
v1.13.0,CLOUDINARY-261: Adding spinset support to PGW
May 20, 2020
d76d15e
CLOUDINARY-277: Changed texts on system.xml
May 24, 2020
84488e9
v1.12.0: Fixed set limit on ProductGalleryApiQueue
May 24, 2020
ce91e96
CLOUDINARY-277
May 24, 2020
c939648
CLOUDINARY-277
May 24, 2020
1926554
CLOUDINARY-277
May 24, 2020
4b4352f
CLOUDINARY-277
May 24, 2020
fb932fd
v1.13.0: Updated CSP whitelist
May 27, 2020
f1491c3
v1.13.0: minor fix on product-gallery plugin
May 31, 2020
d70d2cc
v1.13.0,CLOUDINARY-276: Increased max filename size to 180 on Uploade…
Jun 1, 2020
a015820
v1.13.0,CLOUDINARY-257: Removed extension from publicId on PGW for vi…
Jun 3, 2020
aaf42fe
v1.13.0,CLOUDINARY-281: Allow addig product videos without file exten…
Jun 7, 2020
51b53f8
v1.13.0,CLOUDINARY-261: Added UI for adding spinsets to product gallery
Jun 14, 2020
9d8f863
v1.13.0: spinset minor fixes
Jun 21, 2020
2aad5f2
v1.13.0: csp whitelist update
Jun 21, 2020
fdd33d8
v1.13.0: csp whitelist update
Jun 21, 2020
4671e2f
CLOUDINARY-261: minor changes on spinset
Jun 24, 2020
8b4de7a
v1.13.0: Minor changes on spinset popup design
Jul 5, 2020
d569a5c
v1.13.0: Added CLD spinset support to the product-gallery API
Jul 8, 2020
db5310b
v1.13.0: Improved system.xml for product-gallery
Jul 8, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Api/ProductGalleryManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ interface ProductGalleryManagementInterface
* @param string|null $roles
* @param string|null $label
* @param bool|int|null $disabled
* @param string $cldspinset
* @return string
*/
public function addItem($url, $sku, $publicId = null, $roles = null, $label = null, $disabled = 0);
public function addItem($url = null, $sku = null, $publicId = null, $roles = null, $label = null, $disabled = 0, $cldspinset = null);

/**
* Add multiple gallery items to one or more products from Cloudinary URLs.
Expand Down
7 changes: 7 additions & 0 deletions Api/ResourcesManagementInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,11 @@ public function getImage();
* @return string
*/
public function getVideo();

/**
* GET for getSpinestFirstImage api
*
* @return string
*/
public function getResourcesByTag();
}
60 changes: 49 additions & 11 deletions Block/Adminhtml/Product/Helper/Form/Gallery/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
namespace Cloudinary\Cloudinary\Block\Adminhtml\Product\Helper\Form\Gallery;

use Cloudinary\Cloudinary\Helper\MediaLibraryHelper;
use Cloudinary\Cloudinary\Model\ProductSpinsetMapFactory;
use Magento\Backend\Block\Template\Context;
use Magento\Catalog\Model\Product\Media\Config;
use Magento\Framework\Json\DecoderInterface;
use Magento\Framework\Json\EncoderInterface;

/**
Expand All @@ -29,27 +31,43 @@ class Content extends \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Galle
protected $_template = 'Cloudinary_Cloudinary::catalog/product/helper/gallery.phtml';

/**
* MediaLibraryHelper
* @var array|null
* @var DecoderInterface
*/
protected $mediaLibraryHelper;
protected $_jsonDecoder;

/**
* @param Context $context
* @param EncoderInterface $jsonEncoder
* @param Config $mediaConfig
* @param MediaLibraryHelper $mediaLibraryHelper
* @param array $data
* @var MediaLibraryHelper
*/
protected $_mediaLibraryHelper;

/**
* @var ProductSpinsetMapFactory
*/
protected $_productSpinsetMapFactory;

/**
* @method __construct
* @param Context $context
* @param EncoderInterface $jsonEncoder
* @param DecoderInterface $jsonDecoder
* @param Config $mediaConfig
* @param MediaLibraryHelper $mediaLibraryHelper
* @param ProductSpinsetMapFactory $productSpinsetMapFactory
* @param array $data
*/
public function __construct(
Context $context,
EncoderInterface $jsonEncoder,
DecoderInterface $jsonDecoder,
Config $mediaConfig,
MediaLibraryHelper $mediaLibraryHelper,
ProductSpinsetMapFactory $productSpinsetMapFactory,
array $data = []
) {
parent::__construct($context, $jsonEncoder, $mediaConfig, $data);
$this->mediaLibraryHelper = $mediaLibraryHelper;
$this->_jsonDecoder = $jsonDecoder;
$this->_mediaLibraryHelper = $mediaLibraryHelper;
$this->_productSpinsetMapFactory = $productSpinsetMapFactory;
}

/**
Expand All @@ -61,7 +79,7 @@ public function __construct(
*/
public function getCloudinaryMediaLibraryWidgetOptions($multiple = true, $refresh = false)
{
if (!($cloudinaryMLoptions = $this->mediaLibraryHelper->getCloudinaryMLOptions($multiple, $refresh))) {
if (!($cloudinaryMLoptions = $this->_mediaLibraryHelper->getCloudinaryMLOptions($multiple, $refresh))) {
return null;
}

Expand All @@ -83,7 +101,7 @@ public function getCloudinaryMediaLibraryWidgetOptions($multiple = true, $refres
'useDerived' => false,
'addTmpExtension' => true,
'cloudinaryMLoptions' => $cloudinaryMLoptions,
'cloudinaryMLshowOptions' => $this->mediaLibraryHelper->getCloudinaryMLshowOptions(null),
'cloudinaryMLshowOptions' => $this->_mediaLibraryHelper->getCloudinaryMLshowOptions(null),
]
);
}
Expand All @@ -106,4 +124,24 @@ public function escapeHtmlAttr($string, $escapeSingleQuote = true)
}
return htmlspecialchars((string)$string, ENT_COMPAT, 'UTF-8', false);
}

/**
* Returns image json
*
* @return string
*/
public function getImagesJson()
{
$images = $this->_jsonDecoder->decode(parent::getImagesJson());
if ($images) {
foreach ($images as &$image) {
if ($image['media_type'] === 'image') {
$cldspinset = $this->_productSpinsetMapFactory->create()->getCollection()->addFieldToFilter("image_name", $image['file'])->setPageSize(1)->getFirstItem();
$image['cldspinset'] = $cldspinset ? $cldspinset->getCldspinset() : "";
}
}
return $this->_jsonEncoder->encode($images);
}
return '[]';
}
}
62 changes: 62 additions & 0 deletions Command/ProductGalleryApiQueueProcess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Cloudinary\Cloudinary\Command;

use Cloudinary\Cloudinary\Cron\ProductGalleryApiQueue;
use Magento\Framework\App\State as AppState;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class ProductGalleryApiQueueProcess extends Command
{
/**
* @var AppState
*/
private $appState;

/**
* @var ProductGalleryApiQueue
*/
private $job;

/**
* @method __construct
* @param AppState $appState
* @param ProductGalleryApiQueue $job
*/
public function __construct(
AppState $appState,
ProductGalleryApiQueue $job
) {
parent::__construct('cloudinary:product-gallery-api-queue:process');

$this->appState = $appState;
$this->job = $job;
}

/**
* Configure the command
*
* @return void
*/
protected function configure()
{
$this->setName('cloudinary:product-gallery-api-queue:process');
$this->setDescription('Process queued items for product gallery API');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->appState->setAreaCode(\Magento\Framework\App\Area::AREA_CRONTAB);
return $this->job
->setOutput($output)
->execute();
}
}
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Ajax/RetrieveImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Cloudinary\Cloudinary\Controller\Adminhtml\Ajax;

use Cloudinary\Cloudinary\Core\ConfigurationInterface;
use Cloudinary\Cloudinary\Model\Framework\File\Uploader;
use Cloudinary\Cloudinary\Model\MediaLibraryMapFactory;
use Magento\Backend\App\Action\Context;
use Magento\Catalog\Model\Product\Media\Config as ProductMediaConfig;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Controller\Result\RawFactory as ResultRawFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\File\Uploader;
use Magento\Framework\Filesystem;
use Magento\Framework\HTTP\Adapter\Curl;
use Magento\Framework\Image\AdapterFactory as ImageAdapterFactory;
Expand Down
2 changes: 1 addition & 1 deletion Controller/Adminhtml/Cms/Wysiwyg/Images/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Controller\Result\JsonFactory;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\File\Uploader;
use Cloudinary\Cloudinary\Model\Framework\File\Uploader;
use Magento\Framework\Filesystem;
use Magento\Framework\HTTP\Adapter\Curl;
use Magento\Framework\Image\AdapterFactory;
Expand Down
Loading