Skip to content

Commit

Permalink
Merge pull request #63 from magento-nord/develop
Browse files Browse the repository at this point in the history
[Nord] GA Bug fixes
  • Loading branch information
Korshenko, Olexii(okorshenko) committed Oct 29, 2015
2 parents ec5598b + 1a584f8 commit 3e1f5a4
Show file tree
Hide file tree
Showing 47 changed files with 2,186 additions and 740 deletions.
22 changes: 12 additions & 10 deletions app/code/Magento/BundleImportExport/Model/Export/RowCustomizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Magento\CatalogImportExport\Model\Import\Product as ImportProductModel;
use Magento\Bundle\Model\ResourceModel\Selection\Collection as SelectionCollection;
use Magento\ImportExport\Controller\Adminhtml\Import;
use Magento\ImportExport\Model\Import as ImportModel;

/**
* Class RowCustomizer
Expand Down Expand Up @@ -90,20 +91,21 @@ class RowCustomizer implements RowCustomizerInterface
* Prepare data for export
*
* @param \Magento\Catalog\Model\ResourceModel\Product\Collection $collection
* @param int $productIds
* @param int[] $productIds
* @return $this
*/
public function prepareData($collection, $productIds)
{
$collection->addAttributeToFilter(
$productCollection = clone $collection;
$productCollection->addAttributeToFilter(
'entity_id',
['in' => $productIds]
)->addAttributeToFilter(
'type_id',
['eq' => \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE]
);

return $this->populateBundleData($collection);
return $this->populateBundleData($productCollection);
}

/**
Expand Down Expand Up @@ -214,9 +216,9 @@ protected function getFormattedBundleSelections($optionValues, SelectionCollecti
'price_type' => $this->getPriceTypeValue($selection->getSelectionPriceType())
];
$bundleData .= $optionValues
. ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
. implode(
ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
array_map(
function ($value, $key) {
return $key . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR . $value;
Expand All @@ -240,9 +242,9 @@ function ($value, $key) {
protected function getFormattedOptionValues($option)
{
return 'name' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
. $option->getTitle() . ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
. $option->getTitle() . ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
. 'type' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
. $option->getType() . ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
. $option->getType() . ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR
. 'required' . ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
. $option->getRequired();
}
Expand Down Expand Up @@ -290,7 +292,7 @@ protected function cleanNotBundleAdditionalAttributes($dataRow)
{
if (!empty($dataRow['additional_attributes'])) {
$additionalAttributes = explode(
ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
$dataRow['additional_attributes']
);
$dataRow['additional_attributes'] = $this->getNotBundleAttributes($additionalAttributes);
Expand All @@ -314,10 +316,10 @@ protected function getNotBundleAttributes($additionalAttributes)
$cleanedAdditionalAttributes .= $attributeCode
. ImportProductModel::PAIR_NAME_VALUE_SEPARATOR
. $attributeValue
. ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
. ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR;
}
}

return rtrim($cleanedAdditionalAttributes, ImportProductModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
return rtrim($cleanedAdditionalAttributes, ImportModel::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR);
}
}
32 changes: 20 additions & 12 deletions app/code/Magento/CatalogImportExport/Model/Export/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
namespace Magento\CatalogImportExport\Model\Export;

use Magento\ImportExport\Model\Import;
use \Magento\Store\Model\Store;
use \Magento\CatalogImportExport\Model\Import\Product as ImportProduct;

Expand Down Expand Up @@ -638,7 +639,7 @@ protected function updateDataWithCategoryColumns(&$dataRow, &$rowCategories, $pr
}
$categories[] = $categoryPath;
}
$dataRow[self::COL_CATEGORY] = implode(ImportProduct::PSEUDO_MULTI_LINE_SEPARATOR, $categories);
$dataRow[self::COL_CATEGORY] = implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $categories);
unset($rowCategories[$productId]);

return true;
Expand Down Expand Up @@ -672,7 +673,7 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows)
self::COL_ATTR_SET,
self::COL_TYPE,
self::COL_CATEGORY,
'_product_websites',
self::COL_PRODUCT_WEBSITES,
],
$this->_getExportMainAttrCodes(),
[self::COL_ADDITIONAL_ATTRIBUTES],
Expand All @@ -683,7 +684,7 @@ protected function setHeaderColumns($customOptionsData, $stockItemRows)
'crosssell_skus',
'upsell_skus',
],
['additional_images', 'additional_image_labels']
['additional_images', 'additional_image_labels', 'hide_from_product_page']
);
// have we merge custom options columns
if ($customOptionsData) {
Expand Down Expand Up @@ -901,7 +902,7 @@ protected function collectRawData()

if (!empty($additionalAttributes)) {
$data[$itemId][$storeId][self::COL_ADDITIONAL_ATTRIBUTES] =
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalAttributes);
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalAttributes);
} else {
unset($data[$itemId][$storeId][self::COL_ADDITIONAL_ATTRIBUTES]);
}
Expand Down Expand Up @@ -981,7 +982,7 @@ protected function hasMultiselectData($item, $storeId)
protected function collectMultiselectValues($item, $attrCode, $storeId)
{
$attrValue = $item->getData($attrCode);
$optionIds = explode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $attrValue);
$optionIds = explode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $attrValue);
$options = array_intersect_key(
$this->_attributeValues[$attrCode],
array_flip($optionIds)
Expand Down Expand Up @@ -1040,21 +1041,28 @@ protected function addMultirowData($dataRow, $multiRawData)
foreach ($multiRawData['rowWebsites'][$productId] as $productWebsite) {
$websiteCodes[] = $this->_websiteIdToCode[$productWebsite];
}
$dataRow['_product_websites'] =
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $websiteCodes);
$dataRow[self::COL_PRODUCT_WEBSITES] =
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $websiteCodes);
$multiRawData['rowWebsites'][$productId] = [];
}
if (!empty($multiRawData['mediaGalery'][$productId])) {
$additionalImages = [];
$additionalImageLabels = [];
$additionalImageIsDisabled = [];
foreach ($multiRawData['mediaGalery'][$productId] as $mediaItem) {
$additionalImages[] = $mediaItem['_media_image'];
$additionalImageLabels[] = $mediaItem['_media_label'];

if ($mediaItem['_media_is_disabled'] == true) {
$additionalImageIsDisabled[] = $mediaItem['_media_image'];
}
}
$dataRow['additional_images'] =
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImages);
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImages);
$dataRow['additional_image_labels'] =
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImageLabels);
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImageLabels);
$dataRow['hide_from_product_page'] =
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $additionalImageIsDisabled);
$multiRawData['mediaGalery'][$productId] = [];
}
foreach ($this->_linkTypeProvider->getLinkTypes() as $linkTypeName => $linkId) {
Expand All @@ -1074,7 +1082,7 @@ protected function addMultirowData($dataRow, $multiRawData)
$multiRawData['linksRows'][$productId][$linkId] = [];
asort($associations);
$dataRow[$colPrefix . 'skus'] =
implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, array_keys($associations));
implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, array_keys($associations));
}
}
$dataRow = $this->rowCustomizer->addData($dataRow, $productId);
Expand All @@ -1085,7 +1093,7 @@ protected function addMultirowData($dataRow, $multiRawData)
foreach (array_keys($this->collectedMultiselectsData[$storeId][$productId]) as $attrKey) {
if (!empty($this->collectedMultiselectsData[$storeId][$productId][$attrKey])) {
$dataRow[$attrKey] = implode(
ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR,
$this->collectedMultiselectsData[$storeId][$productId][$attrKey]
);
}
Expand Down Expand Up @@ -1161,7 +1169,7 @@ protected function optionRowToCellString($option)
$result[] = $key . ImportProduct::PAIR_NAME_VALUE_SEPARATOR . $value;
}

return implode(ImportProduct::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $result);
return implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $result);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function __construct(ObjectManagerInterface $objectManager, $customizers
* Prepare data for export
*
* @param mixed $collection
* @param int $productIds
* @param int[] $productIds
* @return mixed|void
*/
public function prepareData($collection, $productIds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface RowCustomizerInterface
* Prepare data for export
*
* @param mixed $collection
* @param int $productIds
* @param int[] $productIds
* @return mixed
*/
public function prepareData($collection, $productIds);
Expand Down
Loading

0 comments on commit 3e1f5a4

Please sign in to comment.