0

Magentoサイト(Magento 1.8.1.0)を古いサーバーから新しいサーバーに移行しました。統合の問題を解決する方法サイト移行後にPOSシステムを搭載したMagentoストア?

しかし、Winepos統合拡張機能を使用することはできません。

私たちのサイトはWinepos systemに接続されています。このMagento拡張機能は、移行作業の前に操作されています。

これはWinepos API manualです。

現時点では、一部のPHPモジュールが新しいサーバーにインストールされていないと思われます。

しかし、インストールされていないPHPモジュールはわかりません。すべてのPHPモジュールが新しいサーバーにインストールされたようです。

Wineposと統合するMagento拡張は次のとおりです。この拡張は2つのファイルで構成されています。

のConfig.xml

<config> 
<global> 
    <events> 
    <checkout_onepage_controller_success_action> 
     <observers> 
     <igor_winepos_order_success_observer> 
      <type>singleton</type> 
      <class>igor_Winepos_Model_Wineposobserver</class> 
      <method>checkoutSuccessObserve</method> 
     </igor_winepos_order_success_observer> 
     </observers> 
    </checkout_onepage_controller_success_action> 
    </events> 
    </global> 
    </config> 

wineposobserver.php

class igor_Winepos_Model_Wineposobserver extends Varien_Event_Observer { 

    function customlog($obj) { 
    ob_start(); 
    var_dump($obj); 
    $out1 = ob_get_contents(); 
    ob_end_clean(); 
    $f = fopen('/tmp/log.txt', 'ab'); 
    fwrite($f, $out1); 
    fclose($f); 
    } 

    public function __construct() { 
    } 

    public function checkoutSuccessObserve($observer) { 
    // $event = $observer->getEvent(); 
    $order_ids = $observer->getData('order_ids'); 
    if(gettype($order_ids) == 'array' && count($order_ids) == 1) { 
     $the_order = Mage::getModel('sales/order')->load($order_ids[0]); 
     Mage::helper('globalfunc')->registerOrderWithWinePOSAsynchronousWithTimeout($the_order); 
    } 
} 
} 

私はApacheのログに次のようになっています:

PHPの警告:PHPのスタートアップ:apc.shm_segmentsを設定MMAPモードでUnknown 0行目で無視[Sun Apr 30 06:32:30 2017] [注意] Apache/2.2.22(Ubuntu)mod_ssl/2.2.22 OpenSSL/1.0.1 confi gured - 私はPOSシステムと統合するための新しいモジュールを作成し、正常に在庫の同期を実現し、通常の操作

285: function registerOrderWithWinePOSAsynchronousWithTimeout($the_order) { 
286  try { 
287  $items = $the_order->getAllItems(); 
... 
426   $ordered_raw_item = $ordered_products_raw_items[$ordered_product_id]; 
428:   $product_winepos_id = trim(strval($product->getResource()->getAttribute('winepos_id')->getFrontend()->getValue($product))); 
429 
430   $item_element = $doc->createElement('item'); 
432   $item_num_element = $doc->createElement('item-num'); 
433:   $item_num_element->appendChild($doc->createTextNode(strval($product_winepos_id))); 
434   $item_element->appendChild($item_num_element); 
... 
466  $the_xml = $doc->saveXML(); 
468:  // $post_result = Mage::helper('globalfunc')->post_to_api_winepos('https://wines-in-november.vznlink.com/orders', $the_xml, 'admin276975', '8dc670fb943dc2c0a1415405cdf00e3ec579c4e6', 8, 10); 
470:  return Mage::helper('globalfunc')->delayed_post_to_winepos($the_xml); 
471  } catch(Exception $e) { 
472  $this->customlog($e); 
... 
475 } 
+0

PHP/Apacheのエラーログを見て、そこに役立つヒントがあるかどうかを確認してください。 – halfer

+0

それはあまりにも深刻に見えません、それは単なる警告です。 Wineposに独自の拡張機能がインストールされている場合は、これをサーバーにインストールするだけですか?私はまだあなたが経験している問題がどんなものなのか、それほど確信が持てません。たとえば、操作の画面上のエラーが出ていますか? – halfer

+0

残念ながら、wineposはMagentoとMagentoを統合するためにMagento拡張を提供することはできません。しかし、サポートチームに尋ねたところ、彼らはAPIマニュアルを提供しました。 https://api.vznlink.com/help現時点で、顧客がオフライン店を通じて当社のサイトで製品を購入すると、wineposは当社のMagentoサイトで商品の在庫を減らすように製品インベントリを管理する必要があります。しかし、wineposは私たちのマゼンタサイトを制御しません。真実を伝えるために、ソースコード全体は変更されていません。唯一の変更はサーバー設定です。ハッカーの攻撃のため、新しいサーバーに移行しました。 –

答えて

1

を再開。 この作業はcronジョブで行う必要があります。これを行うために、私は3つの個別のスクリプトファイルを作成しました。 また、POSプロバイダは、在庫情報を含む注文製品情報をftp経由でtxtファイルとして各時間間隔で提供する必要があります。

lftp -u [username],[password] -e'set ftp:passive-mode false; cd files; put data.txt; quit' [folder name] 

cronジョブの操作ブロックは次のとおりです。

cron_file_mover.php

$start = microtime(true); 
    shell_exec('cp /home/files/data.txt /var/www/vhosts/magento/'); 
    shell_exec('chown -R www-data:www-data /var/www/vhosts/magento/'); 
    $end = microtime(true); 
    echo 'Run time: '.round($end-$start, 4).'s'; 

cron_pos_post_script.php

Utils::initMagento(); $MAX_RETRIES = 5; 
$delayed_jobs = Utils::mageGetRows("select * from delayed_jobs where job_type = 'pos_order' and status = 'todo' order by created_at DESC"); 
$current_index = 0; 
foreach($delayed_jobs as $delayed_job) { 
    $current_index += 1; 
    $retry_count = intval($delayed_job['retry_count']); 
    $retry_count += 1; 
    $post_result = Mage::helper('globalfunc')->post_to_api_pos('https://vznlink.com/orders', $delayed_job['job_details'], 'admin', 'fd93d2de58ab', 8, 10); 
    Utils::mageSqlExecute("update delayed_jobs set status = 'done' where id = " . $delayed_job['id']); 

Utils::mageSqlExecute("update delayed_jobs set status = '" . $new_status . "', retry_count = " . $retry_count . " where id = " . $delayed_job['id']); 
} 

cron_pos_update_script.php

$PATH_TO_FILE = '/var/www/vhosts/magento/data.txt'; 

function read_pos_file($path_to_file) { 
    $min_count_required_for_product = 12; 
    $f = fopen($path_to_file, 'rb'); 
    $text = trim(fread($f, 100000000)); 
    fclose($f); 
    $lines = preg_split('/\r\n|\r|\n/i', $text); 
    $products = array(); 
    foreach($lines as $line) { 
    $product = preg_split('/\t/i', trim($line)); 
    if(count($product) >= $min_count_required_for_product) { 
     $product[0] = strval(trim($product[0])); 
     $product[1] = strval(trim($product[1])); 
     $product[2] = strval(trim($product[2])); 
     $product[11] = intval(strval(trim($product[11]))); 
     $products []= $product; 
    } 
} 
    return $products; 
} 

function update_stock_for_stock_item($product_id, $new_stock) { 
    $stock_item = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product_id); 
    $stock_item->setData('qty', $new_stock); 
    if($new_stock > 0) { 
     $stock_item->setData('is_in_stock', 1); 
    } 
    $stock_item->save(); 
} 
    $products = read_pos_file($PATH_TO_FILE); 
    $total_count = 0; $processed_count = 0; 
    foreach($products as $product) { 
    $total_count += 1; 
    $item_number = $product[0]; 
    $new_stock = $product[11]; 
    if($new_stock < 0) { 
     $new_stock = 0; 
    } 
    $products_matching_item_number = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('pos_id')->addFieldToFilter('pos_id', $item_number)->getItems(); 
    if(count($products_matching_item_number) == 1) { 
     $products_matching_item_number = array_values($products_matching_item_number); 
     $matching_product = $products_matching_item_number[0]; 
     $matching_product_id = $matching_product->getId(); 
     update_stock_for_stock_item($matching_product_id, $new_stock); 
     $processed_count += 1; 
    } 
} 

cronジョブの設定は次のとおりです。

10 * * * * /usr/bin/php /var/www/vhosts/magento/pos/cron_winepos_post_script.php &> /dev/null 
10 * * * * /usr/bin/php /var/www/vhosts/magento/pos/cron_winepos_update_script.php &> /dev/null 
20 * * * * /usr/bin/php /var/www/vhosts/magento/pos/cron_pos_file_mover.php &> /dev/null 

POSシステムから提供されたPOSデータ、cronジョブ設定、更新スクリプト操作を確認してください。

関連する問題