/** * Get the export path of the media * * Examples: * - files/sku-001/front_view/en_US/ecommerce * - files/sku-002/manual/ecommerce * - files/sku-003/back_view/en_US * - files/sku-004/insurance * * @param AbstractProductMedia $media * * @return string */ public function getExportPath(AbstractProductMedia $media) { if ($media->getFilePath() === null) { return ''; } $value = $media->getValue(); $attribute = $value->getAttribute(); $target = sprintf('files/%s/%s', $value->getEntity()->getIdentifier(), $attribute->getCode()); if ($attribute->isLocalizable()) { $target .= '/' . $value->getLocale(); } if ($attribute->isScopable()) { $target .= '/' . $value->getScope(); } return $target . '/' . $media->getOriginalFilename(); }