public function callbackColumnTitle($value, $row, $column, $isExport) { $value = '<div style="margin-left: 3px; margin-bottom: 3px;">' . $this->getHelper('Data')->escapeHtml($value) . "</div>"; $id = $row->getId(); $generalId = $row->getData('general_id'); $categoryLinkTitle = $this->getHelper('Data')->escapeHtml('Show Categories'); $notFoundText = $this->__('Categories Not Found'); $value .= <<<HTML <div style="margin-left: 3px; margin-bottom: 10px; font-size:10px; line-height: 1.1em"> <a href="javascript:void(0)" onclick="ListingGridHandlerObj.productSearchHandler.showAsinCategories( this, {$id}, '{$generalId}', {$this->productId})"> {$categoryLinkTitle} </a> <div id="asin_categories_{$id}"></div> <div id="asin_categories_not_found_{$id}" style="display: none; font-style: italic">{$notFoundText}</div> </div> HTML; if (!$this->listingProduct->getChildObject()->getVariationManager()->isVariationProduct() || $this->listingProduct->getChildObject()->getVariationManager()->isIndividualType()) { if (!$row->getData('is_variation_product')) { return $value; } } else { if (!$row->getData('is_variation_product')) { return $value; } } if ($row->getData('is_variation_product') && $row->getData('bad_parent')) { return $value; } $variations = $row->getData('variations'); if ($this->listingProduct->getChildObject()->getVariationManager()->isRelationParentType()) { $magentoProductAttributesHtml = ''; $magentoProductAttributesJs = ''; $destinationAttributes = array_keys($variations['set']); $this->matcherAttributes->setMagentoProduct($this->listingProduct->getMagentoProduct()); $this->matcherAttributes->setDestinationAttributes($destinationAttributes); if ($this->matcherAttributes->isAmountEqual()) { $magentoProductAttributesJs .= '<script type="text/javascript">'; $magentoProductAttributesHtml .= '<div style="margin-bottom: 5px;"><span style="margin-left: 10px; font-size: 11px; font-weight: bold; color: #808080; display: inline-block; width: 250px;">' . $this->__('Magento Attributes') . '</span><span style="margin-left: 10px; font-size: 11px; font-weight: bold; color: #808080; display: inline-block;">' . $this->__('Amazon Attributes') . '</span></div>'; $matchedAttributes = $this->matcherAttributes->getMatchedAttributes(); $attributeId = 0; foreach ($matchedAttributes as $magentoAttr => $amazonAttr) { $magentoProductAttributesHtml .= '<span style="margin-left: 10px; font-size: 11px; color: #808080; display: inline-block; width: 250px;">' . ucfirst(strtolower($magentoAttr)) . '</span>'; $magentoProductAttributesHtml .= '<input type="hidden" value="' . $this->getHelper('Data')->escapeHtml($magentoAttr) . '" id="magento_product_attribute_' . $attributeId . '_' . $id . '">'; $magentoProductAttributesHtml .= <<<HTML <select class="select admin__control-select amazon_product_attribute_{$id}" onchange="ListingGridHandlerObj.productSearchHandler.attributesChange(this)" style="width: 250px; margin-left: 10px; margin-bottom: 7px; font-size: 11px; background-position: calc(100% - 12px) -38px, 100%, calc(100% - 3.2rem) 0;" id="amazon_product_attribute_{$attributeId}_{$id}"> HTML; if (!array_key_exists($amazonAttr, $variations['set'])) { $magentoProductAttributesHtml .= '<option class="empty" value=""></option>'; } foreach ($variations['set'] as $attrKey => $attrData) { $selected = ''; if ($attrKey == $amazonAttr) { $selected = 'selected'; $magentoProductAttributesJs .= <<<JS ListingGridHandlerObj.productSearchHandler.attributesChange({id:"magento_product_attribute_{$magentoAttr}_{$id}"}); JS; } $attrKey = $this->getHelper('Data')->escapeHtml($attrKey); $magentoProductAttributesHtml .= '<option value="' . $attrKey . '" ' . $selected . '>' . $attrKey . '</option>'; } $magentoProductAttributesHtml .= '</select><br/>'; $attributeId++; } $magentoProductAttributesJs .= '</script>'; $magentoProductAttributesHtml .= '<div id="variations_' . $id . '" style="display: none;">' . json_encode($variations) . '</div>'; } else { $matchedAttributes = json_encode($this->matcherAttributes->getMatchedAttributes(), JSON_FORCE_OBJECT); $destinationAttributes = json_encode($destinationAttributes); foreach ($variations['set'] as $attribute => $options) { $variations['set'][$attribute] = array_values($options); } $amazonVariations = json_encode($variations); $magentoAttributesText = $this->__('Magento Attributes'); $amazonAttributesText = $this->__('Amazon Attributes'); $searchHandler = 'ListingGridHandlerObj.productSearchHandler'; $value .= <<<HTML <form id="matching_attributes_form_{$id}" action="javascript:void(0)" style="margin-left: 10px"> <div class="matching-attributes-table" style="display:table;padding-left:10px;font-size: 11px;color: #808080;"> <div class="matching-attributes-table-header" style="display: table-row; font-weight: bold; height: 20px;"> <div style="display:table-cell; width: 250px;"> <span>{$magentoAttributesText}</span> </div> <div style="display:table-cell; padding-left: 10px;"> <span>{$amazonAttributesText}</span> </div> </div> </div> </form> </div> HTML; if ($this->matcherAttributes->isSourceAmountGreater()) { $magentoProductVariationsSet = $this->listingProduct->getMagentoProduct()->getVariationInstance()->getVariationsTypeStandard(); $magentoProductVariationsSet = json_encode($magentoProductVariationsSet['set']); $productAttributes = json_encode($this->listingProduct->getChildObject()->getVariationManager()->getTypeModel()->getProductAttributes()); $value .= <<<HTML <script type="application/javascript"> {$searchHandler}.searchData[{$id}] = {}; {$searchHandler}.searchData[{$id}].matchingType = {$searchHandler}.MATCHING_TYPE_VIRTUAL_AMAZON; {$searchHandler}.searchData[{$id}].matchedAttributes = {$matchedAttributes}; {$searchHandler}.searchData[{$id}].productAttributes = {$productAttributes}; {$searchHandler}.searchData[{$id}].destinationAttributes = {$destinationAttributes}; {$searchHandler}.searchData[{$id}].magentoVariationSet = {$magentoProductVariationsSet}; {$searchHandler}.searchData[{$id}].amazonVariation = {$amazonVariations}; ListingGridHandlerObj.productSearchHandler.renderMatchedAttributesVirtualView({$id}); </script> HTML; } else { $value .= <<<HTML <script type="application/javascript"> {$searchHandler}.searchData[{$id}] = {}; {$searchHandler}.searchData[{$id}].matchingType = {$searchHandler}.MATCHING_TYPE_VIRTUAL_MAGENTO; {$searchHandler}.searchData[{$id}].matchedAttributes = {$matchedAttributes}; {$searchHandler}.searchData[{$id}].destinationAttributes = {$destinationAttributes}; {$searchHandler}.searchData[{$id}].amazonVariation = {$amazonVariations}; ListingGridHandlerObj.productSearchHandler.renderMatchedAttributesVirtualView({$id}); </script> HTML; } } return $value . $magentoProductAttributesHtml . $magentoProductAttributesJs; } $specificsHtml = ''; $specificsJs = '<script type="text/javascript">'; // match options for individual if ($this->listingProduct->getChildObject()->getVariationManager()->isIndividualType() && $this->listingProduct->getChildObject()->getVariationManager()->getTypeModel()->isVariationProductMatched()) { $channelVariations = array(); foreach ($variations['asins'] as $asin => $asinAttributes) { $channelVariations[$asin] = $asinAttributes['specifics']; } $this->matcherAttributes->setMagentoProduct($this->listingProduct->getMagentoProduct()); $this->matcherAttributes->setDestinationAttributes(array_keys($variations['set'])); if ($this->matcherAttributes->isAmountEqual() && $this->matcherAttributes->isFullyMatched()) { $matchedAttributes = $this->matcherAttributes->getMatchedAttributes(); $this->matcherOptions->setMagentoProduct($this->listingProduct->getMagentoProduct()); $this->matcherOptions->setDestinationOptions($channelVariations); $this->matcherOptions->setMatchedAttributes($matchedAttributes); $productOptions = $this->listingProduct->getChildObject()->getVariationManager()->getTypeModel()->getProductOptions(); $requestedChildAsin = $this->matcherOptions->getMatchedOptionGeneralId($productOptions); } } if (empty($requestedChildAsin)) { $requestedChildAsin = $row->getData('requested_child_id'); } $selectedOptions = array(); if ($requestedChildAsin) { $selectedOptions = $variations['asins'][$requestedChildAsin]['specifics']; } $specificsHtml .= '<form action="javascript:void(0);">'; $attributesNames = '<span style="margin-left: 10px; min-width: 100px; max-width: 250px; font-size: 11px; color: #808080; display: inline-block;">'; $attributeValues = '<span style="margin-left: 5px; display: inline-block;">'; foreach ($variations['set'] as $specificName => $specific) { $attributesNames .= '<span style="margin-bottom: 5px; display: inline-block;">' . ucfirst(strtolower($specificName)) . '</span><br/>'; $attributeValues .= '<input type="hidden" value="' . $this->getHelper('Data')->escapeHtml($specificName) . '" class="specifics_name_' . $id . '">'; $attributeValues .= <<<HTML <select class="select admin__control-select specifics_{$id}" onchange="ListingGridHandlerObj.productSearchHandler.specificsChange(this)" style="width: 250px; margin-bottom: 5px; font-size: 11px; background-position: calc(100% - 12px) -38px, 100%, calc(100% - 3.2rem) 0;" id="specific_{$specificName}_{$id}"> HTML; $attributeValues .= '<option class="empty" value=""></option>'; if (!empty($requestedChildAsin)) { foreach ($specific as $option) { $selected = ''; if ($selectedOptions[$specificName] == $option) { $selected = 'selected'; } $option = $this->getHelper('Data')->escapeHtml($option); $attributeValues .= '<option value="' . $option . '" ' . $selected . '>' . $option . '</option>'; } } $attributeValues .= '</select><br/>'; $specificsJs .= <<<JS ListingGridHandlerObj.productSearchHandler.specificsChange({id:"specific_{$specificName}_{$id}"}); JS; } $specificsHtml .= $attributesNames . '</span>'; $specificsHtml .= $attributeValues . '</span>'; $specificsHtml .= '</form>'; $specificsJs .= '</script>'; $variationAsins = json_encode($variations['asins']); $variationTree = json_encode($this->getChannelVariationsTree($variations)); $specificsJsonContainer = <<<HTML <div id="parent_asin_{$id}" style="display: none">{$generalId}</div> <div id="asins_{$id}" style="display: none;">{$variationAsins}</div> <div id="channel_variations_tree_{$id}" style="display: none;">{$variationTree}</div> HTML; return $value . $specificsHtml . $specificsJsonContainer . $specificsJs; }