Category: WP / Joomla! / Magento / Shopify / Drupal / Moodle / Zimbra

Magento: 设置产品列表默认排序方式 How to sort Magento products by date added as default

方法一: 安装插件 Sort By Date( 方法二: 非插件 Today I had to change Magento default products list sorting to sort by product’s date. In fact we don’t need to sort by date, just by entity_id which is product ID in Magento… Read More

Magento: 添加first name 和 last name到newsletter Add additional fields to your newsletter form and show a popup for subscription.

1. 首先,自定义添加区域,安装插件 Extended Newsletter Subscription (   下载包:Mediarocks_NewsletterExtended-0.3.5 2. 添加到footer your theme is located at /app/design/frontend/default/mytemplate/layout/local.xml <?xml version="1.0"?> <layout version="0.1.0"> <!-- Default layout, loads most of the pages --> <default> <remove name="left.newsletter" /> <!-- if you want to remove the… Read More

Magento 添加 google font Adding a google fonts into Magento

方法一: In your theme  located at  app/design/frontend/YOUR_THEME/YOUR_TEMPLATE/layout/local.xml just add the code below: <?xml version="1.0"?> <layout> <default><!-- use for all pages --> <reference name="head"> <action method="addLinkRel"><rel>stylesheet</rel><href>//</href></action> </reference> </default> </layout>   方法二: In your theme  located at  app/design/frontend/YOUR_THEME/YOUR_TEMPLATE/layout/page.xml just add the code… Read More

Magento: 自动生成产品SKU Auto generated SKU when add product in magento

方法一: Open /app/design/adminhtml/default/default/template/catalog/product/edit.phtml and add the following code to the bottom of the file: <?php $dbread = Mage::getSingleton('core/resource')->getConnection('core_read'); $sql = $dbread->query("SELECT * FROM catalog_product_entity ORDER BY created_at DESC LIMIT 1"); $res = $sql->fetch(); ?> <script type="text/javascript"> if(document.getElementById('sku').value == ""){ document.getElementById('sku').value… Read More

Magento: 设置category类别为必填 How to make product category selection required

You can rewrite the method Mage_Adminhtml_Catalog_ProductController::validateAction() and check if the product is new and category_ids hasn’t been sent through POST then throw an exception. Something like this: app/code/core/Mage/Adminhtml/controllers/Catalog/ProductController.php public function validateAction() { $response = new Varien_Object(); $response->setError(false); try { $productData…

Magento: 单产品(product)或者当前类别(category)最大和最小价格 Min/Max Product Price in a Category

1. 当前类别最大最小价格: $minPrice = Mage::getModel('catalog/product')->getCollection() ->addStoreFilter() ->addAttributeToSelect('price') ->addAttributeToSort('price', 'ASC')->getFirstItem()->getMinimalPrice()*1; $maxPrice = Mage::getModel('catalog/product')->getCollection() ->addStoreFilter() ->addAttributeToSelect('price') ->addAttributeToSort('price', 'DESC')->getFirstItem()->getMinimalPrice()*1; 2 当前产品最大最小价格: $categoryModel = Mage::getModel('catalog/category')->load($id); // Replace with Id of Cat $productColl = Mage::getModel('catalog/product')->getCollection() ->addCategoryFilter($categoryModel) ->addAttributeToSort('price', 'asc') ->setPageSize(1) ->load(); $lowestProductPrice = $productColl->getFirstItem()->getPrice(); $productColh =… Read More

Magento: Mage::getResourceModel, Mage::getModel 和 Mage::getSingleton() 的区别 when to use Mage::getResourceModel, Mage::getModel and Mage::getSingleton()

Perfect differece with example for getsingleton and getmodel. Mage::getSingleton() Mage::getSingleton() will first check if the same class instance exists or not in the memory. If the instance exists then it will return the same object from the memory. So Mage::getSingleton()… Read More

Magento: 获取客户信息 Get Customer’s Full Name, First Name, Last Name and Email Address

1.  获取已登录客户信息 // Check if any customer is logged in or not if (Mage::getSingleton('customer/session')->isLoggedIn()) { // Load the customer's data $customer = Mage::getSingleton('customer/session')->getCustomer(); $customer->getPrefix(); $customer->getName(); // Full Name $customer->getFirstname(); // First Name $customer->getMiddlename(); // Middle Name

Magento: 获取商店名称及邮件地址 Get Store Email Addresses

General Contact /* Sender Name */ Mage::getStoreConfig('trans_email/ident_general/name'); /* Sender Email */ Mage::getStoreConfig('trans_email/ident_general/email'); Sales Representative /* Sender Name */ Mage::getStoreConfig('trans_email/ident_sales/name'); /* Sender Email */ Mage::getStoreConfig('trans_email/ident_sales/email'); Customer Support /* Sender Name */ Mage::getStoreConfig('trans_email/ident_support/name'); /* Sender Email */ Mage::getStoreConfig('trans_email/ident_support/email'); Custom Email 1 /*… Read More

Magento: 客户登陆验证 How magento store password and validate password

Magento uses MD5 and salt algorithems to store password for customer as well admin user. How magento create encrypted password Magento create encrypted password with, Mage::getModel('core/encryption')->decrypt($password); Here is the logic of decrypt($password) function, $password = "12345678"; $salt = "at"; $encyPasswod… Read More


范例:从 迁移到。 将原来网站文件中的var文件中的cache和session文件删除,将media中的缓存文件删除。然后将所有文件制作成一个压缩包,以减少文件体积,方便转移。 将压缩包转移到新的服务器域名指向的文件夹,解压。 一、首先要通过phpMyAdmin备份整个magento的数据库。备份数据并且存为.SQL. 二、接着打开你的备份文件(.SQL),查找并且替换所有的 “” 到“”. 必须在导入数据之前完成,不然新的MAGENTO将会全部瘫痪。 三、 接着别关闭你的备份文件(.SQL),还有重要一步就是必须强制关闭相关的“数据库关键字的关系”。 请拷贝下面代码放在你的SQL代码的顶部: SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT; SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS; SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION; SET NAMES utf8; SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0; 接着将下面的代码放在你的SQL代码的底部: SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;… Read More