$sk = $firstproduct->getSku (); $productId = $product->getIdBySku ( $sk ); // echo $productId."\n"; print_r( $product->load ( $productId )); } exit; */ $gp = new Gorilla_Greatplains_Model_Soap(); //$return = $gp->getProductBySku('8705P09'); //3000L09 //3000S09 // 8855P27B $return = $gp->getProductBySku('3000L12'); print_r($return); exit; //$return = $gp->getOfflineOrderSummary("5156005"); echo "----------";
/** * Query GP for updates. Provides GP with a list of orders. Response may include other orders. * * @param $orderarray - array of order numbers we want to know the status of from GP. * @return mixed - response from GP */ private function getOrdersFromGp($orderarray) { $gp = new Gorilla_Greatplains_Model_Soap(); $d = $gp->updateOrder($orderarray); return $d->getData(); }
<?php require_once '../../app/Mage.php'; umask(0); Mage::app('default'); $sku = '3410S12'; $gpmp = new Gorilla_Greatplains_Model_Product(); // $gpmp->UpdateProductData(); $gp = new Gorilla_Greatplains_Model_Soap(); $data = $gp->getProductBySku($sku); print '<pre>'; print_r($data); print '</pre>'; $products = Mage::getModel('catalog/product')->getCollection() ->addFieldToFilter('type_id', array('in' => array('simple', 'virtual', 'downloadable'))) ->addAttributeToFilter(array( array( // last update time is more than 24 hours before we 'attribute' => 'last_gp_update', // started running this script 'to' => date ("Y-m-d H:i:s", time() ), 'datetime' => true ), // OR array( // last update isn't set for this product 'attribute' => 'last_gp_update', 'null' => true ), array( // OR
public function run2($id, $q) { $status = Gorilla_Queue_Model_Queue::STATUS_OPEN; $order = Mage::getModel('sales/order')->loadByIncrementId($id); $this->orderQueuelog('get by order increment id '); $orderId = is_object($order) ? $order->getId() : null; if (!is_object($order) || empty($orderId)) { $this->orderQueuelog('didnt work. get by order id instead.'); $order = Mage::getModel('sales/order')->load($id); } $orderId = is_object($order) ? $order->getId() : null; if (!is_object($order) || empty($orderId)) { $status = Gorilla_Queue_Model_Queue::STATUS_ABORTED; $q->releaseLock($status); return $q; } $gp = new Gorilla_Greatplains_Model_Soap(); $this->orderQueuelog(print_r($order->getData(), true)); $no = $gp->createNewOrder($order); $orderCreationResponse = $no; Mage::log("gp->createNeOrder({$id})", null, 'fed.log', true); $error = $no->getErrors(); //Mage::log($orderCreationResponse, null, 'fed.log', true); $no = !empty($no->_return) && !empty($no->_return[0]) ? $no->_return[0]->CreateNewOrderResult : ''; $pos = stripos($no, "Success"); Mage::log('no 2' . $no, null, 'fed.log', true); if ($pos === false) { /** * Add soap request and response logging */ $soapClient = $gp->getSoapClient(); if ($soapClient instanceof SoapClient) { $q->setSoapRequest($soapClient->__getLastRequest()); } if ($soapClient->__getLastResponse()) { $q->setErrorMessage($error); $q->setSoapResponse($soapClient->__getLastResponse()); } else { $q->setErrorMessage($orderCreationResponse->_return[0]); $q->setSoapResponse($orderCreationResponse->_return[0]); } $q->updateFailedAttempt(); //$q->setShortDescription($error); $status = Gorilla_Queue_Model_Queue::STATUS_PROCESSING; Mage::log('Export failed:', null, 'fed.log', true); Mage::log($no, null, 'fed.log', true); } else { Mage::log('in success', null, 'fed.log', true); $q->setErrorMessage($error); /** * Add soap request and response logging */ $soapClient = $gp->getSoapClient(); if ($soapClient instanceof SoapClient) { $q->setSoapRequest($soapClient->__getLastRequest()); $q->setSoapResponse($soapClient->__getLastResponse()); } Mage::log('Success orderId=' . $orderId . ' return=' . $no->_return[0]->CreateNewOrderResult, null, 'fed.log', true); $q->updateSuccessfulAttempt(); $status = Gorilla_Queue_Model_Queue::STATUS_SUCCESS; } Mage::log("releaseLock({$status}) order={$id}", null, 'fed.log', true); $q->releaseLock($status); return $q; }
/** * Run script * */ public function run() { // Init GP Soap client $api = new Gorilla_Greatplains_Model_Soap(); // Initialize GP update model as used in hourly cron $model = Mage::getSingleton('greatplains/product'); $model->setGroupIds(); $model->startTime = date ("Y-m-d H:i:s", time() + ( 60 * 60) ); // Override starttime filter so we get all applicable skus $model->processEnabledOnly = true; $skus = array(); $update = (int)$this->getArg('update'); $min = $this->getArg('step'); $min = !empty($min) ? (int)$min : 0; echo "\nSKU=".$this->getArg('sku'); if($sku = $this->getArg('sku')) { $skus[] = $sku; } elseif ($attrSet = $this->getArg('attrset')) { // Get Skus for attr set switch(strtolower($attrSet)) { case 'downloadable': $arrAttrSet = array( 'attribute_set_id' => 15, 'attribute_set_name' => 'Downloadable' ); break; case 'event': $arrAttrSet = array( 'attribute_set_id' => 11, 'attribute_set_name' => 'Event' ); break; } if(isset($arrAttrSet) && is_array($arrAttrSet)) { $skus = $model->getProductSkusByAttributeSet($arrAttrSet); } } echo "Processing " . count($skus) . PHP_EOL; Print_r($skus); if(count($skus)) { $max = ($min + 1)*self::RANGE; if($max > count($skus)) $max = count($skus); //foreach($skus as $sku) { for($i = $min*self::RANGE ; $i < $max; $i++){ echo "Getting Product by SKU: " . PHP_EOL; //$data = $api->getProductBySku($sku); $data = $api->getProductBySku($skus[$i]); //$data->mySku = $sku; $data->mySku = $skus[$i]; // Dump API response print_r($data); // update data in Magento. if($update) { //echo "\nUpdating SKU $sku\n"; echo "\nUpdating SKU $sku\n"; //$model->_updateProductData($data, $sku); $model->_updateProductData($data, $skus[$i]); echo "\nDone.\n"; } } } }