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

Magento模块开发之数据库SQL操作方法说明

今天主要来看Magento中的Mysql4/Resource(资源) 如何对数据库进行操作, 来执行更为复杂的 sql 语句。 在Magento中Model 通常都会继承 Mage_Core_Model_Abstract, 而这个 Abstract 又继承了Varien_Object, 在 Abstract 类中包含许多常用的方法,例如: getId(), load(), save(), delete() 等等…而 Mysql4/Resource Model 则继承 Mage_Core_Model_Mysql4_Abstract, 而这个 Abstract 又继承了 Mage_Core_Model_Resource_Abstract SQL 和 My… Read More

Magento: 通过id获取类别名字等信息 get category by id

<?php // get category model by category id, assume you have known category id, $categoryId $_category = Mage::getModel('catalog/category')->load($categoryId); // category name $categoryName = $_category->getName(); // category description $categoryDescription = $_category->getDescription(); // category url $categoryUrl =… Read More

Magento事件与事件监听

事件和事件监听也许是magento中最有趣的功能之一,因为它允许开发者来扩展magento应用程序中的关键部分。 为了为不同模块之间提供更多的灵活性和便利,magento使用了一种事件/监听模式,这种模式允许模块之间进行松散耦合。 在这个系统中有两部分,一部分是事件分发对象和事件信息,另一部分是监听特定的事件。 一、事件分发 事件的创建和分 发使用Mage::dispatchEvent() 函数。核心团队已经在一些核心关键部分创建了一些事件,例如,模型抽象类Mage_Core_Model_Abstract 在一个模型每次保存的时候调用了两个protected函数—— _beforeSave() 和_afterS… Read More

Magento: 获取类别所有子类别 (无限级别-目录树) Get All Sub Categories

生成分类目录树(Category Tree) $rootcatId = Mage::app()->getStore()->getRootCategoryId(); $categories = Mage::getModel('catalog/category')->getCategories($rootcatId); function get_categories($categories) { $array = '<ul>'; foreach ($categories as $category) { $cat = Mage::getModel('catalog/category')->load($ca… Read More

Magento: 获取产品评论 get all reviews with review summary

1. 根据产品id获取该产品评论 $productId = 1234; $product = Mage::getModel('catalog/product')->load($productId); $storeId = Mage::app()->getStore()->getId(); Mage::getModel('review/review')->getEntitySummary($product, $storeId); $ratingSummary = $product->getRatingSummary(); print_r($ratingSummary->getData());… Read More

解决WP表前缀更换后出现的You do not have sufficient permission

将安装的wordpress表前缀由默认的 wp_修改为其它了,再次登陆后台后出现 You do not have sufficient permissions to access this page. 网上搜索了一下,说是修改检查 wp_usermeta 表中的 wp_capabilities, wp_user_level 数值,但是无效,再搜索发现如下方法解决问题 步骤1. 将wp_usermeta 表中对应wp_前缀设置的 wp_capabilities, wp_user_level,wp_autosave_draft_ids 的前缀 wp_ 修改为新的前缀 步骤2. 将wp_options 中wp_user_roles 前缀 wp_ 修改为新的前缀… Read More

Magento: Service Temporarily Unavailable 解决

My Application was working fine yesterday. I started my Pc today when I tried to start magento I Got This Error message.     Service Temporarily Unavailable     The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later. I am not able to Open even admin page and I

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

方法一: 安装插件 Sort By Date(https://www.magentocommerce.com/magento-connect/sort-by-date.html) 方法二: 非插件 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 world. To accomplish this, we need to edit /app/code/core/Mage/Catalog/Blo… 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 (https://www.magentocommerce.com/magento-connect/extended-newsletter-subscription.html)   下载包:Mediarocks_NewsletterExtended-0.3.5 2. 添加到footer your theme is located at /app/design/frontend/default/mytemplate/layout/local.xml <?xml version="1.0"?> <layo… 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 = $… 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… Read More

Magento: 左栏筛选条件 Select Box / Button / Dropdown List on Layered Navigation

1. 下拉框 Select Box You have plain text and link to those text in Magento Layered Navigation section. You can easily change the display of Layered Navigation links into a selection box / dropdown list. To do so, you need to edit the following file: app/design/frontend/YOUR_PACKAGE/YOUR_THEME/template/catalog/layer/filter.phtml filter.phtml file con… Read More