Magento: how to change image resolution?
Posted by admin in Magento
Magento resizes and sets image resolution to 75 by default. It was a big problem for me so I had to change that.
To reset image resize resolution open file /lib/Varien/Image/Adapter/Gd2.php and find (line 80):
call_user_func($this->_getCallback(’output’), $this->_imageHandler, $fileName);
and replace it with:
if (IMAGETYPE_JPEG === $this->_fileType)call_user_func($this->_getCallback(’output’), $this->_imageHandler, $fileName,100);
else
call_user_func($this->_getCallback(’output’), $this->_imageHandler, $fileName);
For this change to take the effect you need to reset your cache. In your administration go to System -> Cache Management and Clear Image Cache and Refresh All Cache!
Note: Currently I’m using Magento v.1.3.0.
Magetno problem: dbModel read resource does not implement Zend_Db_Adapter_Abstract
Posted by admin in Magento
I recived CSRF Attack Prevention message from Magento team saying that Magento admin has an vulnerability if attacker knows the admin path. Probably like most people I also used /admin/ to access the Magento administration. The message adviced to change it to something specific, so I did. And the page just crashed!?!
I got the error:
dbModel read resource does not implement Zend_Db_Adapter_Abstract
Trace:
#0 /home/chasi/public_html/trgovina/app/code/core/Mage/Core/Model/Mysql4/Collection/Abstract.php(68): Varien_Data_Collection_Db->setConnection(false)
#1 /home/chasi/public_html/trgovina/app/code/core/Mage/Core/Model/Config.php(789): Mage_Core_Model_Mysql4_Collection_Abstract->__construct(Object(Mage_Core_Model_Mysql4_Website))
#2 /home/chasi/public_html/trgovina/app/code/core/Mage/Core/Model/Config.php(831): Mage_Core_Model_Config->getModelInstance(’core_mysql4/web…’, Object(Mage_Core_Model_Mysql4_Website))
#3 /home/chasi/public_html/trgovina/app/Mage.php(345): Mage_Core_Model_Config->getResourceModelInstance(’core/website_co…’, Object(Mage_Core_Model_Mysql4_Website))
#4 /home/chasi/public_html/trgovina/app/code/core/Mage/Core/Model/Abstract.php(200): Mage::getResourceModel(’core/website_co…’, Object(Mage_Core_Model_Mysql4_Website))
#5 /home/chasi/public_html/trgovina/app/code/core/Mage/Core/Model/Abstract.php(205): Mage_Core_Model_Abstract->getResourceCollection()
#6 /home/chasi/public_html/trgovina/app/code/core/Mage/Core/Model/App.php(384): Mage_Core_Model_Abstract->getCollection()
#7 /home/chasi/public_html/trgovina/app/code/core/Mage/Core/Model/App.php(247): Mage_Core_Model_App->_initStores()
#8 /home/chasi/public_html/trgovina/app/Mage.php(432): Mage_Core_Model_App->init(”, ’store’, Array)
#9 /home/chasi/public_html/trgovina/app/Mage.php(453): Mage::app(”, ’store’, Array)
#10 /home/chasi/public_html/trgovina/index.php(52): Mage::run()
#11 {main}
I searched and searcher the forums and Magento pages and got some ideas on what may solve the problem. I had to contact my server provider and ask them to delete all cache (/var/cache/) and session (/var/session/) files. I couldn’t do it myself as my permission wasn’t sufficient. If that still doesn’t solve the problem ask them to restart the Apache aswell. That worked for me and the Magento shop is back and runing
The other solution would be to reinstall Magento. Hmmmm…
Magento speed problem
Posted by admin in Magento
Modifying, I mean uncommenting few lines in your .htaccess file can speed up your magento site a looooot. Find these lines below and just remove # before them.
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip# Insert filter
SetOutputFilter DEFLATE# Netscape 4.x has some problems…
BrowserMatch ^Mozilla/4 gzip-only-text/html# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don’t compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary# Make sure proxies don’t deliver the wrong content
Header append Vary User-Agent env=!dont-vary# enable resulting html compression
php_flag zlib.output_compression on
Magento: Add static block
Posted by admin in Magento
Go to Magento admin uder CMS -> Static Blocks and Add New Block. Insert Block Title, Identifier (for example: my-new-block), set Status to Enabled, insert block Content and Save Block.
If you want to put your static block in left column open file /app/design/frontend/your_theme/your_theme/template/callouts/left_col.phtml and insert code below where you want the static block to apear:
<?php echo $this->getLayout()->createBlock(’cms/block’)->setBlockId(’my-new-block’)->toHtml() ?>
You can put this code wherever you want the block to apear, for exapmle right_col.phtml, 3columns.phtml, … Sky is your limit …
Magento: Change image background color
Posted by admin in Magento
If possible I always avoid modifing system core files, but in this case I couldn’t find any other solution. So to change your image background color open file /app/code/core/Mage/Catalog/Model/Product/Image.php and find:
protected $_backgroundColor = array(255, 255, 255);
and replace it with:
protected $_backgroundColor = array(0, 0, 0);
This will change the white background color to black. Change array(0, 0, 0) to whatever color you need.
Magento: How to activate new theme?
Posted by admin in Magento
Upload your new theme folders to right folders:
/app/design/frontend/new_theme/new_theme/
/skin/design/frontent/new_theme/new_theme/
Go to Admin Panel under System -> Design and click Add Design Change button. In Custom Design drop down menu select you new theme and save it.
That’s it, your new theme is activated!
Magento: Image zoom: set initial zoom
Posted by admin in Magento
The main product image needed to be zoomed in a little when page loads.
Open file: /js/varien/product.js and find at arounf line 89:
sliderValue:0,
and replace the value with the needed zoom value:
sliderValue:0.2,
Then find at around line 94:
this.scale(0);
and replace the value with the same zoom value:
this.scale(0.2);
Magento: Display default Add to cart quantity
Posted by admin in Magento
On product page the add to cart quantity field is empty, but I would like to display quantity value 1 or minimal add to quantity value.
Open file: /app/design/frontend/darila/darila/template/catalog/product/view/addtocart.phtml and find line
<input name=”qty” class=”input-text qty” id=”qty” maxlength=”12″ value=”<?php echo $this->getMinimalQty($_product) ?>” type=”text” />
and replace it with:
<input name=”qty” class=”input-text qty” id=”qty” maxlength=”12″ value=”<?php if($_product->isSaleable()): ?><?php echo $this->getMinimalQty($_product)== null?1:$this->getMinimalQty($_product) ?><?php else: ?><?php echo $this->getMinimalQty($_product)== null?0:$this->getMinimalQty($_product) ?><?php endif; ?>” type=”text” />
Magento: onepage checkout problem
Posted by admin in Magento
In the checkout process only step 1 and step 2 are active. I can not access step3: Shipping methods. I didn’t use standard magento classes in my page layout, I used #right instead .col-right and this is what solved my checkout problem:
Open file: /skin/frontend/darila/darila/js/opcheckout.js and find at around line 50:
var updater = new Ajax.Updater($$(’.col-right’)[0], this.progressUrl, {method: ‘get’, onFailure: this.ajaxFailure.bind(this)});
and replace .col-right with whatever class you used (in my case I used #right)
var updater = new Ajax.Updater($$(’#right’)[0], this.progressUrl, {method: ‘get’, onFailure: this.ajaxFailure.bind(this)});
Checkout process works great now.
osCommerce: IE image display problem
Posted by admin in osCommerce, tips
Some updates occured on our server and all osCommerce sites broke down in Internet Explorer. Mozilla worked just fine. The problem was that no images were displayed on site.
This solved my problem:
- Open file:
/catalog/includes/aplication_top.php - Find line:
$request_type = (getenv(’HTTPS’) == ‘on’) ? ‘SSL’ : ‘NONSSL’;
- Replace it with:
$request_type = (getenv(’HTTPS’) == ‘off’) ? ‘SSL’ : ‘NONSSL’;
That’s it, worked for me …


