/
AbstractHandler.php
56 lines (52 loc) · 1.59 KB
/
AbstractHandler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Copyright © 2016 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\ProductVideo\Model\Plugin\Catalog\Product\Gallery;
/**
* Abstract class for catalog product gallery handlers plugins.
*/
abstract class AbstractHandler
{
/**
* @var array
*/
protected $videoPropertiesDbMapping = [
'value_id' => 'value_id',
'store_id' => 'store_id',
'video_provider' => 'provider',
'video_url' => 'url',
'video_title' => 'title',
'video_description' => 'description',
'video_metadata' => 'metadata'
];
/**
* @var \Magento\Catalog\Model\ResourceModel\Product\Gallery
*/
protected $resourceModel;
/**
* @param \Magento\Catalog\Model\ResourceModel\Product\Gallery $resourceModel
*/
public function __construct(
\Magento\Catalog\Model\ResourceModel\Product\Gallery $resourceModel
) {
$this->resourceModel = $resourceModel;
}
/**
* @param \Magento\Catalog\Model\Product $product
* @param \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
* @return array
*/
protected function getMediaEntriesDataCollection(
\Magento\Catalog\Model\Product $product,
\Magento\Eav\Model\Entity\Attribute\AbstractAttribute $attribute
) {
$attributeCode = $attribute->getAttributeCode();
$mediaData = $product->getData($attributeCode);
if (!empty($mediaData['images']) && is_array($mediaData['images'])) {
return $mediaData['images'];
}
return [];
}
}