watch 'more mysqld-slow.log | grep Query_time | wc -l; more mysqld-slow.log | grep Query_time;' This can be helpful if your trying to debug slow queries or just capture them as they come in.
Watching a slow query log
- By Heather Mello
- Apr 5, 2016
watch 'more mysqld-slow.log | grep Query_time | wc -l; more mysqld-slow.log | grep Query_time;' This can be helpful if your trying to debug slow queries or just capture them as they come in.
This can have many causes as your search through the internet has obviously found. My problem with this particular issue was I had my products setup properly, so it was not the fact that it was out of stock. This site almost had me excited but only to find out my product creation script already took care of it: http://zaclee.net/magento/errors-magento/stock-item-for-product-is-not-valid So, after some hard core searching, I found that I was not using the proper product object. The only way I could get my auto add to cart working was to use this $product = Mage::getModel('catalog/product')->load($product_id); I had a different product object, ( loading by the sku ) and apparently you can not use that type of object to add items to the cart. 5 hours of my life lost, hopefully to spare yours.
find . -name ".svn" -exec rm -rf {} \;
Lest say you have a need in your Magento store to have an "auto add to cart". This would be in situations where maybe you provide a free sample if they purchase a specific product, or maybe you will attach a warranyt sku to specific products automatically. However, this item your adding to the magneto cart has custom options! This can be tricky. Here is an example function I use when I run into this situation.
protected function _saveCustomOption($product_id, $product, $qty) { // Load up a product that has the custom options and get the attributes, in this case we just have one custom option // This custom option is a text field and our end goal is to populate that with sku-product name $_product = Mage::getSingleton('catalog/product')->load($product_id); $attrs = $_product->getOptions(); foreach($attrs as $attr) { // Loop through all the custom options ( once again we only have one in our scenario ) and assign the values we need
If you have ever received a message similar to:
Fear not, just restart the service and you can log back in again! $ /etc/init.d/webmin stop ( hit enter ) $ /etc/init.d/webmin start ( hit enter ) Viola, service running and you can log back in again.
If you are looking at the view source of your zend framework page, and you notice that your external javascript files and your external css files are being included many times, its because you have echo in front of each line:
<?php echo $this->headLink()->prependStylesheet($this->serverUrl().'/css/style.css'); ?>
<?php echo $this->headLink()->prependStylesheet($this->serverUrl().'/css/colorbox.css'); ?>
<?php echo $this->headScript()->appendFile($this->serverUrl().'/js/jquery.1.7.2.js') ?>
<?php echo $this->headScript()->appendFile($this->serverUrl().'/js/oe.js') ?>
<?php echo $this->headScript()->appendFile($this->serverUrl().'/js/colorbox/jquery.colorbox-min.js') ?>
<?php echo $this->headLink()?>
<?php echo $this->headScript()?>
The way to remove the css and javascript files from being included many times is to do the echo on the headLink() and headScript() after you have set the files and just echo one line:
If you have Magneto 1.0.7.2 and your tired of being logged out of the admin area every few minutes, to adjust that setting: System->Configuration->Admin In the security section, change that to 86400 if you want it to be 1 day, or any value over 60. This will extend your admin time before your logged out! Life is good again!
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
$store_id = Mage::app()->getStore()->getStoreId();
Base Directory: Mage::getBaseDir() Mage::getBaseDir(‘base’) /var/www/magento/ App: Mage::getBaseDir(‘app’) /var/www/magento/app/ Code: code Mage::getBaseDir(‘code’) /var/www/magento/app/code Design: design Mage::getBaseDir(‘design’) /var/www/magento/app/design/ Etc: etc Mage::getBaseDir(‘etc’) /var/www/magento/app/etc Lib: lib Mage::getBaseDir(‘lib’) /var/www/magento/lib Locale: locale Mage::getBaseDir(‘locale’) /var/www/magento/app/locale Media: media Mage::getBaseDir(‘media’) /var/www/magento/media/ Skin: skin Mage::getBaseDir(‘skin’) /var/www/magento/skin/ Var: var Mage::getBaseDir(‘var’) /var/www/magento/var/ Tmp: tmp Mage::getBaseDir(‘tmp’) /var/www/magento/var/tmp Cache: cache Mage::getBaseDir(‘cache’) /var/www/magento/var/cache Log: log Mage::getBaseDir(‘log’) /var/www/magento/var/log Session: session Mage::getBaseDir(‘session’) /var/www/magento/var/session Upload: upload Mage::getBaseDir(‘upload’) /var/www/magento/media/upload Export: export Mage::getBaseDir(‘export’) /var/www/magento/var/export