/** * extract the SalesClass from DOMNOdeList object and map to a known Magento 'backorder' value * @param DOMNodeList $nodes * @param Mage_Catalog_Model_Product $product * @return null */ public function extractStockData(DOMNodeList $nodes, Mage_Catalog_Model_Product $product) { /** @var string */ $value = $this->coreHelper->extractNodeVal($nodes); /** @var int */ $productId = (int) $product->getId(); /** @var array */ $stockData = $this->buildStockData($productId, $value); if (!$productId) { $product->setNewProductStockData($stockData); return null; } $this->saveStockItem($stockData, $productId); return null; }
/** * given an acknowledgment feed file, load into a DOMDocument object * attach it into a DOMXPath object and then query it using a constant * that hold XPath for extracting the related exported file * and then return an array of key acknowledgment map to the given acknowledgment file * and a 'related' key mapped to the extracted exported file in the acknowledgment file * @param string $ackFile the full path to the acknowledgment to extract the exported file related to it * @param string $exportedDir the directory to where exported sent file exists * @return array */ protected function _extractAckExportedFile($ackFile, $exportedDir) { $doc = $this->_coreHelper->getNewDomDocument(); $doc->load($ackFile); $xpath = $this->_coreHelper->getNewDOMXPath($doc); return [self::ACK_KEY => $ackFile, self::RELATED_KEY => $exportedDir . DS . $this->_coreHelper->extractNodeVal($xpath->query(self::XPATH_ACK_EXPORTED_FILE, $this->_coreHelper->getDomElement($doc)))]; }
/** * extract the attribute set name * * @param DOMNodeList $nodes * @param Mage_Catalog_Model_Product $product * @return int */ public function extractAttributeSetValue(DOMNodeList $nodes, Mage_Catalog_Model_Product $product) { $attributeSetName = $this->coreHelper->extractNodeVal($nodes); $attributeSetId = Mage::helper('ebayenterprise_catalog')->getAttributeSetIdByName($attributeSetName); if (is_null($attributeSetId)) { // @todo: move to error confirmation feed $logData = ['attribute_set_name' => $attributeSetName]; $logMessage = 'Attribute Set "{attribute_set_name}" has not yet been setup for this Magento instance.'; $this->logger->warning($logMessage, $this->context->getMetaData(__CLASS__, $logData)); } return $attributeSetId ?: $product->getAttributeSetId(); }