小编ben*_*rks的帖子

未转换的报价记录是否已在Magento中删除?

tl; dr:似乎没有其他开箱即用机制可以删除从未转换为订单的报价记录.

Mage_Sales模块具有用于清除过期报价的计划作业,但这仅删除sales_flat_quote标记为非活动(即is_active = 0)的记录.据我所知,报价仅在报价转换为订单时标记为非活动.如果是这种情况,那么报价表只会越来越大.

参考 Mage_Sales_Model_Observer::cleanExpiredQuotes()

class Mage_Sales_Model_Observer
{
    //...

    public function cleanExpiredQuotes($schedule)
    {
        Mage::dispatchEvent('clear_expired_quotes_before', array('sales_observer' => $this));

        $lifetimes = Mage::getConfig()->getStoresConfigByPath('checkout/cart/delete_quote_after');
        foreach ($lifetimes as $storeId=>$lifetime) {
            $lifetime *= 86400;

            /** @var $quotes Mage_Sales_Model_Mysql4_Quote_Collection */
            $quotes = Mage::getModel('sales/quote')->getCollection();

            $quotes->addFieldToFilter('store_id', $storeId);
            $quotes->addFieldToFilter('updated_at', array('to'=>date("Y-m-d", time()-$lifetime)));
            $quotes->addFieldToFilter('is_active', 0);

            foreach ($this->getExpireQuotesAdditionalFilterFields() as $field => $condition) {
                $quotes->addFieldToFilter($field, $condition);
            }

            $quotes->walk('delete');
        }
        return $this;
    }

    //...
}
Run Code Online (Sandbox Code Playgroud)

magento

19
推荐指数
1
解决办法
7080
查看次数

如何在Magento中以编程方式添加JS?

我需要在块文件中有条件地以编程方式添加JS文件.我试过这些代码:

if (Mage::getStoreConfig('mymodule/settings/enable')) {
$this->getLayout()->getBlock('head')->addJs('path-to-file/file1.js');
} else {
$this->getLayout()->getBlock('head')->addJs('path-to-file/file2.js');
}
Run Code Online (Sandbox Code Playgroud)

但是,无论设置是什么,都不会加载此文件.我甚至试图消除这种情况并仅显式加载一个文件,但它仍然无效.我在这做错了什么?

magento magento-layout-xml

6
推荐指数
2
解决办法
9198
查看次数

管理/会话模型中isFirstPageAfterLogin方法的目的是什么?

我知道这个方法在哪里使用,但我想知道谁对这个问题有权威的答案?

magento

4
推荐指数
1
解决办法
297
查看次数

在Magento中显示可配置产品的简单产品库存

我对Magento很新.据我了解,我需要形成可配置的产品,以管理不同大小的产品.我想在产品视图页面中单独显示每种尺寸的库存数量.这可能吗?我的属性名称是'size'.我使用以下代码来获取库存数量.但是,它无法获得可配置产品的单个简单产品的库存数量.

<?php   
$__manStock = $_product->getStockItem()->getManageStock();

$__invAmt =(int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty('small');
if ($__manStock > 0)
    {
    echo $this->__("$__invAmt");
    }
?>
Run Code Online (Sandbox Code Playgroud)

inventory magento configurable-product

4
推荐指数
1
解决办法
1万
查看次数

在重定向之前在Magento中发送事件

我在Magento中使用事件调度时遇到了问题.

我正在使用controller_action_predispatch从URL中的参数设置前端会话变量.

现在,问题似乎是,当用户最初访问该网站时,他们可能会借助一个页面将其重定向到基本URL(例如example.com到www.example.com).但由于某种原因,重定向后,会话变量丢失了......

有任何想法吗?

谢谢.

编辑:

添加使用的代码:

public function grabRef($observer) {
    $ref = Mage::app()->getRequest()->getParam('ref', $default);
    if (isset($ref) && !is_null($ref) and !empty($ref)) {

        Mage::getSingleton('core/session',array('name'=>'frontend'))->setRefid($ref);

    }
}
Run Code Online (Sandbox Code Playgroud)

php session redirect magento

3
推荐指数
1
解决办法
1476
查看次数

检查是否存在后置参数

我目前正在研究应该处理发布请求的Magento控制器.

我可以检查请求是否是POST并提取参数,但我想知道是否有一种标准方法来检查请求期间是否已传递特定参数.

你会怎么做?

magento magento-1.7

3
推荐指数
1
解决办法
2939
查看次数

Magento集合表达

如何在集合中使用表达式.

更具体,我想SELECT CAST(qty_shipped AS UNSIGNED).

我尝试过这样的东西: addExpressionFieldToSelect('qty_shipped','CAST(qty_shipped AS UNSIGNED)',null) 但是它出于某种原因附加了表名.

谢谢.

collections expression magento

2
推荐指数
1
解决办法
4518
查看次数

数据库中的Magento优惠券实体

我正在尝试开发一个涉及使用优惠券的Magento插件.显然,在环顾四周之后,我发现我找到了一个来源,提到使用'salesrule'表作为优惠券.但是,当我查看我的数据库时,我找不到它.但是我确实找到了3张提到"优惠券"的表格,名为"coupon_aggregated","coupon_aggregated_order"和"coupon_aggregated_updated".

我只是想知道3个表之间有什么区别所以我可以开始使用它们了吗?我正在使用最新版本的Magento.

提前谢谢你们.

magento coupon magento-1.7

2
推荐指数
1
解决办法
8848
查看次数

如何在Magento查询中添加"order by"

我为magento安装了一个脚本.它允许在订单上添加注释.所以它显示了对订单网格的一个评论.

问题是它没有按"created_at"列对注释进行排序.我不知道如何设置顺序.

这是代码的一部分:

 protected function _initSelect()
{
    parent::_initSelect();

    // Join order comment
    $this->getSelect()->joinLeft(
        array('ordercomment_table' => $this->getTable('sales/order_status_history')),
        'main_table.entity_id = ordercomment_table.parent_id AND ordercomment_table.comment IS NOT NULL',
        array(
            'ordercomment' => 'ordercomment_table.comment',
        )
    )->group('main_table.entity_id');

    return $this;
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

zend-framework sql-order-by magento

2
推荐指数
1
解决办法
3829
查看次数

覆盖Mage_Catalog_Block_Layer_View是magento中的一个错误?

我试图覆盖Mage_Catalog_Block_Layer_Viewmagento.我试图覆盖它Mage_Catalog_Block_Layer_State并且它正常工作,但layer_view重写没有.这是一个错误吗?

<global>
    <blocks>
        <catalog>
            <rewrite>
                <layer_view>Mymodule_Catalog_Block_Layer_View</layer_view>
            </rewrite>
        </catalog>
    </blocks>
</global>


<global>
    <blocks>
        <catalog>
            <rewrite>
                <layer_state>Mymodule_Catalog_Block_Layer_State</layer_state>
            </rewrite>
        </catalog>
    </blocks>
</global>
Run Code Online (Sandbox Code Playgroud)

请帮帮我.我几个小时都在尝试

magento

1
推荐指数
1
解决办法
1303
查看次数

在magento中编辑配置值(magento扩展)

我创建了一个Magento扩展,它使用/ etc/dir(对于我的模块)中的system.xml文件向我的配置添加字段.Magento 1.5目前是我的目标系统,但我也打算将兼容性扩展到1.4和.16

<merchantid translate="label">
      <label>Merchant ID</label>
      <frontend_type>text</frontend_type>
      <sort_order>20</sort_order>
      <show_in_default>1</show_in_default>
      <show_in_website>1</show_in_website>
      <show_in_store>0</show_in_store>
</merchantid>
Run Code Online (Sandbox Code Playgroud)

我试图在运行时填充此字段的值.目前,我在我的插件中运行它:Mage::getStoreConfig('payment/mymerchant/merchantid');它返回字段中填充的值.

我需要能够以编程方式更新此字段,我试过这个:

 $installer = new Mage_Core_Model_Resource_Setup();
                $installer->startSetup();
                $installer->setConfigData("payment/mymerchant/merchantid", "TEST");
                $installer->endSetup();
Run Code Online (Sandbox Code Playgroud)

但没有成功.我也无法通过谷歌搜索问题,因为大多数结果似乎并不相关.

有没有人知道如何设置这些值?

magento

1
推荐指数
1
解决办法
2773
查看次数

按产品属性过滤Magento类别集合?

我有一个Magento网站,其中包含大量目录(10,000种产品)和一个相当深的类别树.

所有产品类别均来自顶级"所有产品"类别.
所有产品都有"品牌"的下拉属性.

我想要做的是允许访问者从类别树的顶部开始,并在选择或不选择品牌的情况下向下浏览"所有产品"树.问题是我们需要在每个级别显示下一级子类别,如果品牌不适用,我不想显示空白类别.

例如,如果树看起来像这样,而且一个在"螺丝刀页面"上,我们希望类型和长度类别都可见.

  1. 所有产品
    • 螺丝刀
      • 菲利普斯
        • 2"
        • 3"
        • 5"
      • 平头
        • 1"
        • 3"
        • 5"

通过创建类别集合,我可以做到这一点而不用担心品牌过滤器:

    $_category  = $this->getCurrentCategory();
    $current_level = $_category->getLevel(); 
    $collection = $_category->getCollection(); 

    $collection->addAttributeToSelect('url_key')
                ->addAttributeToSelect('name')
                ->addAttributeToSelect('parent_id')
                ->addAttributeToFilter('is_active', 1)
                ->addAttributeToFilter('level',array('in'=>array($current_level+1,$current_level+2)))
                ->setOrder('position','ASC')
                ->load();
Run Code Online (Sandbox Code Playgroud)

根据我的研究,似乎无法通过产品属性直接过滤类别集合.

假设这是真的:实现这一目标的最佳方法什么?我已经想到并初步尝试了一些想法:

  • 创建按品牌过滤的产品集合并循环遍历它以获取所有相关类别并构建树(看起来这样效率非常低)
  • 尝试利用分层导航输出类别(如果我们只查看一个级别,这将有效 - 我无法获得过滤的"第二"级别.)
  • 放弃过滤的想法,并在新的"按品牌浏览"类别下复制类别树(我想远离这一点,以便更新产品不需要更新两个重复的树.)

在此先感谢您的帮助.如果您需要澄清问题,请告诉我.

magento

1
推荐指数
1
解决办法
7289
查看次数

无法解决"货币'美元'未找到"错误

我在前端和后端收到此消息:处理您的请求时出错.

当我删除缓存文件夹(var/cache,/ tmp&/ session)时,我得到了前端再次工作,直到我访问商店中的任何页面并且价格合理.后端很难再次工作(现在不是).

检查错误日志我得到了一大堆以"货币'美元'未找到"开头.这一切都是在经过一些小的改动后开始发生的,包括将货币代码的顺序从"$ 100.00"更改为"100,00€",我通过编辑/lib/Zend/Locale/Data/es.xml(西班牙语)来完成规范)这里:

  <currencyFormats>
    <currencyFormatLength>
     <currencyFormat>
        <pattern>¤ #,##0.00</pattern>
     </currencyFormat>
   </currencyFormatLength>
   <unitPattern count="other">{0} {1}</unitPattern>
 </currencyFormats>
Run Code Online (Sandbox Code Playgroud)

我尝试返回以前的格式,然后将原始文件复制回来.其他东西必须在某个地方破碎,我找不到它.

以下是错误日志中的最后几个步骤的摘要(您是否需要它们?)

a:5:{i:0; s:24:"货币'美元'未找到"; i:1; s:3740:"#0/home/content/32/9343032/html/app/code/core/Mage/Core/Model/Locale.php(575):Zend_Currency - > __ construct('USD',Object(Zend_Locale))

#1 /home/content/32/9343032/html/app/code/core/Mage/Directory/Model/Currency.php(233):Mage_Core_Model_Locale-> currency('EUR')

#2 /home/content/32/9343032/html/app/code/core/Mage/Directory/Model/Currency.php(216):Mage_Directory_Model_Currency-> formatTxt(NULL,Array)

#3 /home/content/32/9343032/html/app/code/core/Mage/Directory/Model/Currency.php(197):Mage_Directory_Model_Currency-> formatPrecision(NULL,2,Array,true,false)

#4 /home/content/32/9343032/html/app/code/core/Mage/Adminhtml/Block/Dashboard/Bar.php(82):Mage_Directory_Model_Currency-> format(NULL)

请帮帮我...

谢谢米格尔

frontend backend magento

0
推荐指数
1
解决办法
3665
查看次数