Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Api 站点迁移后如何解决Magento store与POS系统的集成问题?_Api_Magento_Integration_Php Extension_Inventory Management - Fatal编程技术网

Api 站点迁移后如何解决Magento store与POS系统的集成问题?

Api 站点迁移后如何解决Magento store与POS系统的集成问题?,api,magento,integration,php-extension,inventory-management,Api,Magento,Integration,Php Extension,Inventory Management,我们将我们的Magento站点Magento 1.8.1.0从旧服务器迁移到新服务器 但是,我们不能再使用Winepos集成扩展 我们的站点已与连接,并且此Magento扩展在迁移工作之前已运行 这是 此时,我们认为一些PHP模块没有安装在我们的新服务器上 但是,我们不知道哪些PHP模块没有安装。似乎所有的PHP模块都安装在我们的新服务器上 与Winepos集成的Magento扩展如下所示。此扩展名由两个文件组成 Config.xml <config> <global>

我们将我们的Magento站点Magento 1.8.1.0从旧服务器迁移到新服务器

但是,我们不能再使用Winepos集成扩展

我们的站点已与连接,并且此Magento扩展在迁移工作之前已运行

这是

此时,我们认为一些PHP模块没有安装在我们的新服务器上

但是,我们不知道哪些PHP模块没有安装。似乎所有的PHP模块都安装在我们的新服务器上

与Winepos集成的Magento扩展如下所示。此扩展名由两个文件组成

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>
我在Apache日志中得到以下信息:

PHP警告:PHP启动:在第0行未知的MMAP模式下忽略apc.shm_段设置[Sun Apr 30 06:32:30 2017][注意]Apache/2.2.22 Ubuntu mod_ssl/2.2.22 OpenSSL/1.0.1已配置-恢复正常操作


我创建了一个与POS系统集成的新模块,并成功地实现了库存同步。 这项工作应该由cron job完成。为此,我创建了三个单独的脚本文件。 此外,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

cron_pos_post_script.php

cron_pos_update_script.php


请记住,检查POS系统提供的POS数据、cron作业设置、检查更新脚本操作。

查看您的PHP/Apache错误日志,看看是否有有用的线索。这看起来不太严重,只是一个警告。如果Winepos有自己的扩展要安装,您能在服务器上安装它吗?我仍然不太确定您到底遇到了什么问题-例如,您是否在操作中出现屏幕错误?不幸的是,winepos无法提供Magento扩展来集成Magento。但是,当我询问支持团队时,他们提供了API手册。此时,当客户通过离线商店在我们的网站上购买产品时,winepos应控制我们的产品库存,以便在我们的Magento网站上减少售出产品的库存。但是,winepos不能控制我们的magento网站。说实话,整个源代码并没有改变。唯一的改变是服务器设置。由于黑客的攻击,我们迁移到了新服务器。对不起,我不知道你的问题是什么,在这种情况下。也许其他人可以帮忙。我想您可能会问如何进行完整的API集成,这将是一个非常广泛的问题。
 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    }
lftp -u [username],[password] -e'set ftp:passive-mode false; cd files; put data.txt; quit' [folder name]
  $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';
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']);
}
$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;
   }
}
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