0

I am attempting to get the quantity of an item by inputting the sku. The following code works great on my WAMP local installation:

require_once('app\Mage.php');
umask(0);
Mage::app();
$sku='TEST1';
$product = Mage::getModel('catalog/product/info')->loadByAttribute('sku',$sku);
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product); 
echo $stock->getQty();

However, when I change to the production server I get the following errors:

PHP Warning:  PHP Startup: apc.shm_size now uses M/G suffixes, please update your ini files in Unknown on line 0
PHP Fatal error:  Uncaught exception 'Zend_Cache_Exception' with message 'can't get apc memory size' in /var/www/html/Example.com/us/lib/Zend/Cache.php:208
Stack trace:
#0 /var/www/html/Example.com/us/lib/Zend/Cache/Backend/Apc.php(191): Zend_Cache::throwException('can't get apc m...')
#1 /var/www/html/Example.com/us/lib/Zend/Cache/Backend/TwoLevels.php(488): Zend_Cache_Backend_Apc->getFillingPercentage()
#2 /var/www/html/Example.com/us/lib/Zend/Cache/Backend/TwoLevels.php(173): Zend_Cache_Backend_TwoLevels->_getFastFillingPercentage('saving')
#3 /var/www/html/Example.com/us/lib/Zend/Cache/Core.php(381): Zend_Cache_Backend_TwoLevels->save('a:7:{s:10:"bloc...', 'JFMG_CORE_CACHE...', Array, NULL)
#4 /var/www/html/Example.com/us/lib/Varien/Cache/Core.php(76): Zend_Cache_Core->save('a:7:{s:10:"bloc...', 'CORE_CACHE_OPTI...', Array, NULL, 8)
#5 /var/www/html/Example.com/us/app/code/core/Mage/Core/Model/Cache.php(349): Varien_Cache_Core->save('a:7:{s:10:"bloc...', 'CORE_CACHE_OPTI...', Array, NULL)
#6 /var/www/html/Example.com/us/app/code/c in /var/www/html/Example.com/us/lib/Zend/Cache.php on line 208

The production server is running Linux so I did change the back slash to forward slash in the first line to:

require_once('app/Mage.php');

"Example.com" is substituted for my domain name. In both cases I am using Magento 1.4.1.1. Any help or comments would be greatly appreciated. Thanks.

4

Your issue is stated right here:

PHP Startup: apc.shm_size now uses M/G suffixes, please update your ini files in Unknown on line 0

Find your apc.ini (or it may be located in your php.ini), and fix the apc.shm_size.

3
  • Yep, pretty much it. Jul 30 '13 at 15:10
  • I corrected the apc.ini file and the error message regarding that is gone. I am still left with the PHP Fatal error though. I did restart the server after changing the apc.ini. Any ideas on what to try next? Thanks.
    – Aaron
    Jul 30 '13 at 21:20
  • It turns out that I can run the php code from the web browser but not from the command line. I've read that I need to add apc.enable_cli = 1 to the apc.ini file to be able to run the code from the command line. Unfortunately, I haven't been able to find out if there are any security or performance implications from adding that. Does anyone know what that will change?
    – Aaron
    Jul 30 '13 at 21:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.