小编Sha*_*351的帖子

Magento - 获取当前产品

我的布局中有一个侧边栏,显示在不同的页面上.

在这个块中,我有一个产品列表,我想在产品页面上选择当前产品.

我正在使用 :

$current_product = Mage::registry('current_product');
Run Code Online (Sandbox Code Playgroud)

获取当前产品,但这仅适用于我第一次加载产品页面.当我选择不同的产品时,上面的代码返回相同的值(第一个产品).

我假设发生这种情况是因为我正在使用Magento缓存.我能做些什么来获得正确的价值?

当我使用时会发生同样的事情:

$currentCategory = Mage::registry('current_category');
Run Code Online (Sandbox Code Playgroud)

侧边栏块是我在这里添加的导航模板:..\app\design\frontend\default\mytheme\template\catalog \navigation\page_left.phtml.

我用这个XML将它添加到布局中:

<block type="catalog/navigation" name="left.navigation.block" as="left.navigation.block" template="catalog/navigation/page_left.phtml"/>
Run Code Online (Sandbox Code Playgroud)

php caching magento

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

Magento:getAttributeText不起作用

我有一个名为"Housing"的下拉属性(属性代码"housing").我想获取产品所选选项的文本,但"getAttributeText"函数不返回任何内容.

我的代码:

$product_object = Mage::getModel('catalog/product')->load($productId);
$housing = $product_object->getHousing();
echo $housing;
echo "<br>";

$housing = $product_object->getAttributeText('housing');
echo $housing;
echo "<br>";

$housing = $product_object->getHousingText();
echo $housing;
echo "<br>";
Run Code Online (Sandbox Code Playgroud)

函数getHousing返回正确的选项id,但"getAttributeText"和"getHousingText"不返回任何内容.

有什么想法吗?

php magento

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

Magento - 向sales_flat_quote_item和sales_flat_order_item添加新列

我正在使用Magento版本1.4.1.1,我想在sales_flat_quote_item表中保存一个值(并传递给它sales_flat_order_item).

我已经找到了这个教程,但我不确定它是否仍然相关(对于Magento版本1.4.1.1),因为它谈到了一个名为的表sales_order,我相信现在sales_flat_order看起来有点不同.

该方法是否仍然有效?如果是这样的-我可以用它sales_flat_quote_itemsales_flat_order_item什么entity_type_id我应该放在称道:

`insert into eav_attribute('entity_type_id','attribute_code','attribute_model','backend_model','backend_type','backend_table','frontend_model','frontend_input','frontend_input_renderer','frontend_label','frontend_class','source_model','is_global','is_visible','is_required','is_user_defined','default_value','is_searchable','is_filterable','is_comparable','is_visible_on_front','is_html_allowed_on_front','is_unique','is_used_for_price_rules','is_filterable_in_search','used_in_product_listing','used_for_sort_by','is_configurable','apply_to','position','note','is_visible_in_advanced_search'  )  
values(11, 'my_new_column', null, '', 'static', '', '', 'text', '','',null, '', 1,1,1,0,'',0,0,0,0,0,0,1,0,0,0,1,'',0,'',0);`
Run Code Online (Sandbox Code Playgroud)

如果在新的Magento版本中不是这样做的话,我应该怎么做?

谢谢,Shani

php magento magento-1.4

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

升级到1.6版后无法重新索引新产品

我已将我的网站从1.4.0.1版升级到1.6版.我删除了网站上的所有产品,并成功完成了"全部重新索引".当我尝试创建新产品而不是再次重新索引时,我收到此错误:

Product Attributes index process unknown error:
exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`.../catalog_product_index_eav`, CONSTRAINT `FK_CAT_PRD_IDX_EAV_ENTT_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`entity_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CAS)' in .../lib/Zend/Db/Statement/Pdo.php:228
Run Code Online (Sandbox Code Playgroud)

我试过TRUNCATE TABLE catalog_product_index_eav但它没有帮助.

我怎样才能解决这个问题?

php magento

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

Magento - 在产品列表中为页面标题添加页码

我有一个扩展,它使用产品列表块按属性显示产品网格过滤器(扩展名为属性信息页面).

在此扩展块的"_prepareLayout"函数中,扩展使用以下代码设置页面的标题和描述:

$head = $this->getLayout()->getBlock('head');
.
.
.
$head->setTitle($title);
head->setDescription($des);
Run Code Online (Sandbox Code Playgroud)

我想以这种格式向标题和描述添加文本:

$page_info = "Page A of B for ";
$title = $page_info . title;
$items_info = "Listings X-Y (out of Z) ";
$des = items_info . $des;
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这个代码,以获取当前页面,最后一页,数字和项目等等:

$html_pager = Mage::getBlockSingleton('page/html_pager');
    $html_pager->setCollection($product_collection);
    $limit = Mage::getSingleton('core/app')->getRequest()->getParam('limit');
    if(empty($limit))
    {
        $limit = 8;
    }

    $html_pager->setLimit($limit);
    $LastPageNumber = $html_pager->getLastPageNum();
    $current_page = $html_pager->getCurrentPage();

    $page_info = "";
    if($current_page > 1)
    {
        $page_info = "Page " . $current_page . " of $LastPageNumber for ";
    } …
Run Code Online (Sandbox Code Playgroud)

php magento

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

标签 统计

magento ×5

php ×5

caching ×1

magento-1.4 ×1