Показаны сообщения с ярлыком Magento. Показать все сообщения
Показаны сообщения с ярлыком Magento. Показать все сообщения

суббота, 10 марта 2012 г.

Magento cms home page with products and pager

Params:
Magento 1.6.0

Problem:
Display products on home page with pager.

Solution:
Without programming you can display products only from one category.
Edit home page in admin panel of your shop.
Admin panel -> CMS -> Pages -> Home page
Insert into "Design" tab the following code
<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
   <action method="setCategoryId">
      <category_id>18</category_id>
   </action>
   <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
      <block type="page/html_pager" name="product_list_toolbar_pager"/>
   </block>
   <action method="setToolbarBlockName">
      <name>product_list_toolbar</name>
   </action>
</block>
</reference>
Change the category_id value for your needs.

суббота, 4 февраля 2012 г.

Magento disable user subscribe success email notification

Params:
Magento 1.6.0

Problem:
In Magento admin you can not disable email notification when user subscribe.  So, look to this solution

Solution:
Find script:
/app/code/core/Mage/Newsletter/Model/Subscriber.php
and comment folloving line in function subscribe($email) :
$this->sendConfirmationSuccessEmail();


PS:
This is bad solution, because  when you upgrade your store to the new version
those changes will be overwritten. If you not so lazy, create package for yourself ;)

пятница, 3 февраля 2012 г.

Magento change amount of emails sended at once

Params:
Magento 1.6.0

Problem:
In Magento I need decrease of emails count wich will be send by cron at once.  Set this value to 8
and send emails every 5 minutes against default 15.

Solution:
Find and edit the following scriots by example.

Change count of emails in one action:
app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
$countOfSubscritions = 8;
app/code/core/Mage/Newsletter/Model/Observer.php
$countOfSubscritions = 8

Change newsletter exec cron  time interval:
/app/code/core/Mage/Newsletter/etc/config.xml
<crontab><jobs><newsletter_send_all><schedule>
<cron_expr>*/5 * * * *</cron_expr>


PS:
This is bad solution, because  when you upgrade your store to the new version
those changes will be overwritten. If you not so lazy, create package for yourself ;)

воскресенье, 25 декабря 2011 г.

PHP sessions across sub domains

Params:
PHP-5.3, Apache-2.2

Problem:
I need a single session for mysite.com and admin.mysite.com domains. I would login on main domain mysite.com, and will be already authorized on sub domains like admin.mysite.com.


Solution:
In script before session start need too setup this session parameters:
session.cookie_path = "/"
session.cookie_domain = ".mysite.com" - dot at the beginning is important, it specify use same sessions on sub domains

Example:
Example for Zend Framework application.


Define site domain name value:
*** public/index.php ***
...
defined('SITE_DOMAIN_NAME')
|| define('SITE_DOMAIN_NAME', (getenv('SITE_DOMAIN_NAME') ? getenv('SITE_DOMAIN_NAME') : 'mysite.com'));
...
It seems, if server value SITE_DOMAIN_NAME is not defined, craete it. We will use it in config file.

You can define SITE_DOMAIN_NAME in .htaccess file, Anyway he need to be configured on every server separately.

*** public/.htaccess ***
...
SetEnv SITE_DOMAIN_NAME mysite.com
...

Further I set session values in config file
*** application/configs/application.ini ***
[production]
...
local.session.cookie_path = "/"
local.session.cookie_domain = "." SITE_DOMAIN_NAME
...
This line  "." SITE_DOMAIN_NAME  is equal to ".mysite.com"

And in Bootstrap.php wee initialize session.
*** application/Bootstrap.php ***
...
protected function _initSession()
{
$localCfg = new Zend_Config($this->getOption('local'), true);
Zend_Session::setOptions($localCfg->session->toArray());
Zend_Session::start();
}
...

воскресенье, 18 декабря 2011 г.

Magento, change emails count in newsletter queue

Params:
Magento 1.6.0

Problem:
When cron execute newsletters, the count of emails which will be send is limited to 20 per request.

Solution:
Notice: This is bad solution!
Edit script app/code/core/Mage/Adminhtml/controllers/Newsletter/QueueController.php
Find string :
$countOfSubscritions = 20;
and set the value which you need. For me is "8" - limit of my hosting (emails count per request).

воскресенье, 4 декабря 2011 г.

Where Magentoconnect manager save downloaded packages

Params:
Magento 1.6.0

Problem:
I have installed some package from magentoconnect, and I want to look inside this package.

Solution:
It saved here:
<path_to_magento_store_folder>/downloader/.cache/community/<package_name>.tgz

вторник, 25 октября 2011 г.

Magento database add table prefix

Problem:
Store setup was without database table prefix.
Now I need to move magento database to existing db with tables from another application.

Parameters:
Magento version 1.6.0

Solution:
Create script "add_db_prefix.php" in your store public catalog. Listing:


<?php
$database_host = "localhost"; // Here database server, ip or domain name
$database_user = "<your_db_user>";
$database_password = "<your_db_user_password>";
$magento_database = "<your_db_name>";
$table_prefix = "mage_"; // Table prefix wich you want!!!

$db = mysql_connect($database_host, $database_user, $database_password);
mysql_select_db($magento_database);
$result = mysql_query("SHOW TABLES") or die('Err');
while (($row = mysql_fetch_array($result)) != false) {
    $old_table = $row[0];
    if (preg_match('/'.$table_prefix.'/', $old_table)) {
        echo "Table $old_table already done<br/>\n";
        continue;
    }

    $new_table = $table_prefix.$old_table;
    echo "Renaming $old_table to $new_table<br/>\n";
    $query = "RENAME TABLE `$old_table`  TO `$new_table`";
    mysql_query($query);
}
?>

Do not forget change db conection data in script!
Follow to the url: http://<your_store_domain_name>/add_db_prefix.php
Now all tables in db with new prefix.
And of course you need setup table prefix in your store config file.
Edit config: "app/etc/local.xml"
Find string: "<table_prefix><![CDATA[]]></table_prefix>"
Put there your new table prefix: "<table_prefix><![CDATA[mage_]]></table_prefix>"

среда, 19 октября 2011 г.

Magento Admin Notification bugfix

Magento v.1.6
Trouble:
Every time when I am login to the admin panel see this message:"Reminder: Change Magento`s default phone numbers and callouts before site launch"
It's really damn annoying.


Sollution:
Copy the file app/code/core/Mage/AdminNotification/Model/Resource/Inbox.php
to app/code/local/Mage/AdminNotification/Model/Resource 
Create these folders if they does not exists.
And edit this php script.
Line 102. Find:
$select = $adapter->select()
                ->from($this->getMainTable())
                ->where('url=?', $item['url']);
Replace it by:$select = $adapter->select()
                ->
from($this->getMainTable())
                ->
where('url=? OR url IS NULL', $item['url'])
                ->
where('title=?', $item['title']);

Delete all your notifications.


Thanks to Payserv http://www.magentocommerce.com/boards/viewthread/246247/

понедельник, 3 октября 2011 г.

Move Magento store to another server


Actions
  • Create DB backup (phpmyadmin or etc.)
  • Import backup to server DB.
  • Copy all magento files to the server.
  • Edit config for DB connection. (app/etc/local.xml)
  • Clear Magento cache folder (var/cache/)

In phpmyadmin.
  1. open table core_config_data
  2. Find rows where column "path" equal "web/unsecure/base_url" and "web/secure/base_url".
  3. Edit these rows. Set appropriate site domain name.

воскресенье, 2 октября 2011 г.

Magento Connect Manager problems

Errors on page Magento Connect Manager(MCM):
1) "Warning: Your Magento folder does not have sufficient write permissions."
2) "Config file does not exists" or something like that
3) MCM tab "Settings" Deployment Type "Local Filesystem" is inactive

Solution (Your magento installation folder here /var/www/<domain_name>/public/):
Change folders permission
> chmod -v 777 /var/www/<domain_name>/public/
> chmod -v 777 /var/www/<domain_name>/public/downloader/