Magento报错General error: 1030 Got error 28 from storage engine
今天早上同事跟我说我写的接口出问题了,上去一看,报SQLSTATE[HY000]: General error: 1030 Got error 28 from storage engine错误,照例百度,原来是服务器的临时空间不足导致。
解决办法:1.清空/tmp目录
2.修改my.cnf中的tmpdir参数,指向具有足够空间目录
今天早上同事跟我说我写的接口出问题了,上去一看,报SQLSTATE[HY000]: General error: 1030 Got error 28 from storage engine错误,照例百度,原来是服务器的临时空间不足导致。
解决办法:1.清空/tmp目录
2.修改my.cnf中的tmpdir参数,指向具有足够空间目录
主要用处就是在Magento中获取指定分类下的产品。
$products = Mage::getModel('catalog/category')->load($category_id) ->getProductCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('status', 1) ->addAttributeToFilter('visibility', 4);
<?php $str = '我住在3号楼A座'; $list = array(); $start = 0; $lengh = mb_strlen($str,'utf8');//这里可以是指定的长度 while (count($list)<$lengh) { $list[] = mb_substr($str, $start,1,'utf8');//也可以用$list .= $start++; } print_r($list); ?>
loadByIncrementId(100000001); // 100000001为订单编号
// 获取订单状态
$status = $order->getStatus();
$state = $order->getState();
echo $status;
echo "\r\n";
echo $state;
// 设置订单状态 $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
$order->save();
Magento订单 有两个状态变量:state和status,这让人困惑,只有测试下了,于是下了个单,然后在Magneto后台处理订单,得出下面的Magento订单状态值。
1. 新订单
state : new
status : pending
2. 配送后
state : processing
status : processing
3. 收款后
state : processing
status : processing
4. 订单完成
state : complete
status : complete
5. 订单取消
state : canceled
status : canceled
6. 订单关闭
state : closed
status : closed
7. 订单挂起
state : holded
status : holded
Magento订单状态 是定义在Magento代码文件app\code\core\Mage\Sales\Model\Order.php中定义了订单的状态常量:
/** * Order model * * Supported events: * sales_order_load_after * sales_order_save_before * sales_order_save_after * sales_order_delete_before * sales_order_delete_after * * @author Magento Core Team <[email protected]> */ class Mage_Sales_Model_Order extends Mage_Sales_Model_Abstract {
/** * Order states */ const STATE_NEW = 'new'; const STATE_PENDING_PAYMENT = 'pending_payment'; const STATE_PROCESSING = 'processing'; const STATE_COMPLETE = 'complete'; const STATE_CLOSED = 'closed'; const STATE_CANCELED = 'canceled'; const STATE_HOLDED = 'holded'; const STATE_PAYMENT_REVIEW = 'payment_review'; // added magento 1.4
/** * Order flags */ const ACTION_FLAG_CANCEL = 'cancel'; const ACTION_FLAG_HOLD = 'hold'; const ACTION_FLAG_UNHOLD = 'unhold'; const ACTION_FLAG_EDIT = 'edit'; const ACTION_FLAG_CREDITMEMO= 'creditmemo'; const ACTION_FLAG_INVOICE = 'invoice'; const ACTION_FLAG_REORDER = 'reorder'; const ACTION_FLAG_SHIP = 'ship'; const ACTION_FLAG_COMMENT = 'comment';
// ... } </[email protected]>
其中,pending_payment, payment_review 是支付(Paypal, Amazon Pay)过程中引入的订单状态。
$categories = Mage::getModel('catalog/category')->getCollection() ->addAttributeToSelect('id') ->addAttributeToSelect('name') ->addAttributeToSelect('url_key') ->addAttributeToSelect('url') ->addAttributeToSelect('is_active');
foreach ($categories as $category) { if ($category->getIsActive()) { // Only pull Active categories $entity_id = $category->getId(); $name = $category->getName(); $url_key = $category->getUrlKey(); $url_path = $category->getUrl(); } }
<?php // load(level-number)?> <?php $categoryIds = Mage::getModel('catalog/category')->load(3)->getChildren() ?> <?php $categoryIds = explode(',', $categoryIds); ?> <?php $count = count($categoryIds); $i=0; ?> <?php foreach ($categoryIds as $categoryId): ?> <?php $category = Mage::getModel("catalog/category")->load($categoryId) ?> <li<?php if (++$i == $count): ?> class="last"<?php endif ?>><a href="<?php echo $category->getUrl() ?>" title="<?php echo $this->stripTags($category->getName()) ?>"><?php echo $this->stripTags($category->getName()) ?></a></li> <?php endforeach ?> $_categoryIds = $_product->getCategoryIds(); foreach ($_categoryIds as $_categoryId) { $_category = Mage::getModel('catalog/category')->load($_categoryId); $_category_name = $_category->getName(); $_category_url = $_category->getUrlPath(); break; }