Skip to content

Commit b56b622

Browse files
Mapping added for age group (#408)
1 parent 433aeb8 commit b56b622

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

app/code/Meta/Catalog/Model/Product/Feed/Builder.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
namespace Meta\Catalog\Model\Product\Feed;
2222

23-
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
2423
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Related;
2524
use Magento\Framework\Exception\NoSuchEntityException;
2625
use Magento\GroupedProduct\Ui\DataProvider\Product\Form\Modifier\Grouped;
@@ -35,7 +34,6 @@
3534
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
3635
use Magento\Framework\Exception\LocalizedException;
3736
use Magento\Framework\Escaper;
38-
use Magento\Catalog\Model\Product\Visibility;
3937
use Magento\Catalog\Model\Product\Attribute\Source\Status;
4038
use Meta\BusinessExtension\Model\System\Config as SystemConfig;
4139

@@ -602,6 +600,26 @@ private function getStatus(Product $product)
602600
return $status == Status::STATUS_ENABLED ? 'active' : 'archived';
603601
}
604602

603+
/**
604+
* Get age group for product
605+
*
606+
* @param Product $product
607+
* @return string
608+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
609+
*/
610+
private function getAgeGroup(Product $product)
611+
{
612+
$ageGroup = '';
613+
if(isset($this->attrMap[self::ATTR_AGE_GROUP])) {
614+
$ageGroup = $product->getData($this->attrMap[self::ATTR_AGE_GROUP]);
615+
}
616+
if (empty($ageGroup)) {
617+
$ageGroup = $this->additionalAttributes->getCorrectText($product, self::ATTR_AGE_GROUP);
618+
}
619+
620+
return $ageGroup ?: '';
621+
}
622+
605623
/**
606624
* Get gender for product
607625
*
@@ -855,6 +873,7 @@ public function buildProductEntry(Product $product)
855873
self::ATTR_ADDITIONAL_IMAGE_URL => $this->getAdditionalImages($product, $images),
856874
self::ATTR_STATUS => $this->getStatus($product),
857875
self::ATTR_GENDER => $this->getGender($product),
876+
self::ATTR_AGE_GROUP => $this->getAgeGroup($product),
858877
self::ATTR_MATERIAL => $this->getMaterial($product),
859878
self::ATTR_PATTERN => $this->getPattern($product),
860879
self::ATTR_SHIPPING_WEIGHT => $this->getWeight($product),
@@ -1012,6 +1031,7 @@ public function getHeaderFields()
10121031
self::ATTR_ADDITIONAL_IMAGE_URL,
10131032
self::ATTR_STATUS,
10141033
self::ATTR_GENDER,
1034+
self::ATTR_AGE_GROUP,
10151035
self::ATTR_MATERIAL,
10161036
self::ATTR_PATTERN,
10171037
self::ATTR_SHIPPING_WEIGHT,

0 commit comments

Comments
 (0)