The first step that you should do to resolve this bug is check your system.log file. In my case error looks like this: Warning: Header may not contain more than a single header, new line detected in D:\Zend\Apache2\htdocs\project1\app\code\core\Mage\Core\Model\Session\Abstract\Varien.php on line 123 Warning: Header may not contain more than a single header, new line detected in […]

Read more

Useful links

http://www.phpliveregex.com/

Read more

Sometimes, after upgrade Magento, and introducing a new template, You may not see it. Why? Because each product can have a changed template to ‘default/default’. Solutions: 1) just save product in admin panel 2) write simple SQL script, updating product attribute ‘custom_design’ to null or set it blank 3) write php code, using Magento API, […]

Read more

Edit app\design\frontend\theme\default\layout\customer.xml add action : 0 to wrapper block, like this: My Account Wrapper my-account 0

Read more

The JVM could not be started. The maximum heap size (-Xmx) might be too large or an antivirus or firewall tool could block the execution.

To resolve this problem, set up new system variable in windows: Variable name: JAVA_OPTS. Variable value -Xms256m -Xmx512m Or just edit file : PhpStorm_Install\bin\PhpStorm.exe.vmoptions by increase or decrease -Xmx and -Xms paremeter

Read more

Delete magento attribute with options and values

$attribute_code = ‘some_attribute_code’; $attribute = Mage::getModel(‘eav/config’)->getAttribute(‘customer_address’,$attribute_code); $options = $attribute->getSource()->getAllOptions(); foreach ($options as $option) { if ($option[‘label’] === ” && $option[‘value’]) { $newOptions[‘value’][$option[‘value’]][] = $option[‘label’]; $newOptions[‘delete’][$option[‘value’]] = $option[‘value’]; } } $installer->addAttributeOption($newOptions); $collection = Mage::getResourceModel(‘eav/entity_attribute_option_collection’) ->setAttributeFilter($attribute->getId()) ->setStoreFilter($attribute->getStoreId()) ->load(); foreach ($collection as $option) { $option->delete(); } $installer->removeAttribute(‘customer_address’, $attribute_code); Info about this type of attribute, may be stored also […]

Read more

MySQL create, update and delete user

Create database mysql> CREATE DATABASE databasename; Query OK, 1 row affected (0,02 sec) Create user mysql> CREATE USER ‘abadowski’@’localhost’ IDENTIFIED BY ‘passwordname’; mysql> GRANT ALL PRIVILEGES ON abadowski.* TO ‘abadowski’@’localhost’ -> WITH GRANT OPTION; Update user mysql> UPDATE mysql.user SET Password=PASSWORD(‘newpasswordname’) WHERE User=’abadowski’; mysql> FLUSH PRIVILEGES; Delete mysql> DROP USER ‘abadowski’@’localhost’; mysql> DROP DATABASE databasename;

Read more

Saving product with data like this: $ids = array(‘1′,’1′,’2’); $_product->setWebsiteIds($ids); makes error : “SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry …”. To avoid this error, just use function array_unique, on $ids array. This solution, i think, could be implemented as default in new version of Magento.

Read more

Remove get param from url

protected function removeQsVar($url, $varName) { $parts = parse_url($url); $queryParams = array(); parse_str(html_entity_decode($parts[‘query’]), $queryParams); unset($queryParams[$varName]); $queryString = http_build_query($queryParams); if(strlen($queryString)>0){ $queryString = ‘?’ . $queryString; } $url = $parts[‘scheme’] . ‘://’ . $parts[‘host’] . $parts[‘path’] . $queryString; return $url; }

Read more

$corehelper = Mage::helper(‘core’); $cheapestrate = 0; if($_product->isSaleable()) { $_product = Mage::getModel(‘catalog/product’)->load($_product->getId()); $quote = Mage::getModel(‘sales/quote’); $quote->getShippingAddress()->setCountryId(‘PL’); $addToCartInfo = (array) $_product->getAddToCartInfo(); $request = new Varien_Object($addToCartInfo); if ($_product->getStockItem()) { $minimumQty = $_product->getStockItem()->getMinSaleQty(); if($minimumQty > 0 && $request->getQty() < $minimumQty){ $request->setQty($minimumQty); } } $_product->getStockItem()->setUseConfigManageStock(false); $_product->getStockItem()->setManageStock(false); $quote->addProduct($_product, $request); $quote->getShippingAddress()->collectTotals(); $quote->getShippingAddress()->setCollectShippingRates(true); $quote->getShippingAddress()->collectShippingRates(); $rates = $quote->getShippingAddress()->getShippingRatesCollection(); $_rates = array(); if($rates->count()){ foreach ($rates […]

Read more