标签: magento

如何从前端控制器生成管理链接?

我想有一个从前端页面到adminhtml页面的链接.我尝试过使用Adminhtml帮助器方法:

Mage::helper('adminhtml')->getUrl('some/admin/path')
Run Code Online (Sandbox Code Playgroud)

和Adminhtml URL模型方法:

Mage::getModel('adminhtml/url')->getUrl('some/admin/path')
Run Code Online (Sandbox Code Playgroud)

但无济于事.我每次都被踢到管理仪表板.

magento

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

如何实现setPagesize的分页,现在返回所有产品

所有我试图在集合上setPageSize(),以便我可以使用它进行分页.

无论我在setPageSize中放入什么整数,我都会收到所有返回的产品.

码:

    <?php

class Rik_Featured_Block_Featured extends
Mage_Core_Block_Template {

    private $_itemPerPage = 2;
    public $_category_id = '' ;
    private $_currentPage = '';

    public function __construct() {
        $custom_var_code = Mage::getModel('core/variable')->loadByCode('homepage_firstrow_prod');
        if(isset($custom_var_code)) echo $this->_category_id = $custom_var_code->getValue('text') ;
        echo $page_var = $this->getRequest()->getParam('p');
        if(isset($page_var)&&$page_var!=0){           
            $this->_currentPage = $page_var;
        }
        if(isset($page_var)&&$page_var == '0'){           
            $this->_currentPage = '1';
        }


    }


    /****************** Here is my setcurpage and setpagesize************************/

        public function allProducts() {
        $collection = $this->_getCollection();
        echo 'col is'.$collection->count();
        /*Setting current page and page size */
        $collection->setCurPage(1);
        $collection->setPageSize($this->_itemPerPage);
        return $collection; …
Run Code Online (Sandbox Code Playgroud)

magento

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

getChildHtml()方法在magento的产品列表页面(类别view.phtml/product list.phtml)中不起作用

我在getToolbarHtml()之后调用list.phtml文件中新创建的引用.但它没有显示任何东西.我的catalog.xml文件类似于:

<reference name="content">
            <block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
                <block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
                    <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
                        <block type="page/html_pager" name="product_list_toolbar_pager"/>

                        <!-- The following code shows how to set your own pager increments -->
                        <!--
                            <action method="setDefaultListPerPage"><limit>4</limit></action>
                            <action method="setDefaultGridPerPage"><limit>9</limit></action>
                            <action method="addPagerLimit"><mode>list</mode><limit>2</limit></action>
                            <action method="addPagerLimit"><mode>list</mode><limit>4</limit></action>
                            <action method="addPagerLimit"><mode>list</mode><limit>6</limit></action>
                            <action method="addPagerLimit"><mode>list</mode><limit>8</limit></action>
                            <action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
                        -->
                    </block>
                    <reference name="newreference">
                        <block type="core/template" name="newreferenceblock" template="newreference.phtml" />
                    </reference>

                    <action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
                    <action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
                    <action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
                    <action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
                    <action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
                    <action method="setToolbarBlockName"><name>product_list_toolbar</name></action>

                </block>
                    </block>
Run Code Online (Sandbox Code Playgroud)

我在引用内部调用引用,事情是我想创建自己的侧边栏.那有什么问题呢?在list.phtml中,我通过以下方式调用我的引用:

<?php echo $this->getChildHtml('newreference') ?>
Run Code Online (Sandbox Code Playgroud)

请帮我.

magento magento-1.6 magento-1.7

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

按属性选项的Magento过滤器集合

我是Magento的新手,我正试图弄清楚如何过滤一系列产品.情况就是这样:我有一个产品有'样式',这是产品的属性(样式的例子:黄铜).我需要获得所有其他具有"黄铜"风格的产品.

我做了一些研究并发现了addFieldToFilter()方法,但它似乎没有工作(或者,很可能,我没有正确使用它):

$same_style_collection = Mage::getModel('catalog/product')->getCollection()
    ->addFieldToFilter(array(array('attribute' => 'name', 'like' => 'brass')));
Run Code Online (Sandbox Code Playgroud)

谁能帮我?这将不胜感激.

php filter magento

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

如何允许缺货产品在magento结账?

我们希望允许客户订购缺货产品,有没有解决方案,我们可以让客户结账缺货产品?

谢谢

php magento magento-1.7

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

Magento flat indexer不会将'image'属性复制到catalog_product_flat表

我正在使用Magento Community 1.7.0.2.

最近我决定在我的商店打开"使用平面目录类别"和"使用平面目录类别"选项.我前端使用'image'属性的所有图像都消失了(它们被默认的图像占位符替换).使用"small_image"或"thumbnail"属性显示的所有图像都会正确显示.

我查看了catalog_product_flat_1表,那里没有'image'列(但是'image_label'列...).我查看了平面索引器代码,并能够打印用于获取插入到平面表中的所有属性的SQL语句:

SELECT `main_table`.*, `additional_table`.* 
FROM `eav_attribute` AS `main_table` 
INNER JOIN `catalog_eav_attribute` AS `additional_table` 
ON additional_table.attribute_id = main_table.attribute_id 
WHERE (main_table.entity_type_id = :entity_id) AND (main_table.backend_type = 'static'     
OR additional_table.is_used_for_promo_rules = 1 OR additional_table.used_in_product_listing = 1 OR additional_table.used_for_sort_by = 1 
OR main_table.attribute_code IN('sku', 'type_id', 'name', 'status', 'visibility', 'price', 'weight', 'url_path', 'url_key', 'thumbnail', 'small_image', 
'tax_class_id', 'special_from_date', 'special_to_date', 'special_price', 'cost', 'is_recurring', 'recurring_profile', 'msrp_enabled', 'msrp',
'msrp_display_actual_price_type', 'enable_googlecheckout', 'gift_message_available', 'price_view', 'price_type', 'shipment_type', 'weight_type', 
'sku_type', 'links_purchased_separately', 'links_title', 'short_description', 'image_label', 'thumbnail_label', 'small_image_label', 'news_from_date',
'news_to_date', 'created_at', …
Run Code Online (Sandbox Code Playgroud)

magento flat

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

PHP正则表达式 - 正斜杠和交替的问题

我有一系列的网址如下:

http://www.somesite.com/de/page
http://www.somesite.com/de/another
http://www.somesite.com/de/page/something
http://www.somesite.com/de/page/bar
Run Code Online (Sandbox Code Playgroud)

我需要搜索文本块并拉动语言并使用正则表达式,如下所示:

/(de|en|jp)/
Run Code Online (Sandbox Code Playgroud)

我正试图找到并替换,通过preg_replace并包括正斜杠:

/de/
/en/
/jp/
Run Code Online (Sandbox Code Playgroud)

但是,这不起作用,也不包括斜杠.我试过逃避斜线\,\\.我试过把针放进去,preg_quote但这打破了交替.

我觉得我在这里错过了一些非常简单的东西!

编辑:

全功能通话:

preg_replace("/(de|en|jp)/", "/".$newLang."/", $url);
Run Code Online (Sandbox Code Playgroud)

-

(标记为magento和wordpress,因为我试图解决当两个CMS都是多语言时统一导航菜单的问题)

php regex wordpress magento

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

如何使用phpMyAdmin更改base_url设置

我在magento后端更改了base_url.现在我的网站无法访问

如何用phpMyAdmin更改base_url设置?

提前致谢!

magento base-url

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

如何在magento中获取远程ip地址?

我使用以下代码显示远程IP地址

    $ip = $_SERVER["REMOTE_ADDR"];
    echo $ip;
Run Code Online (Sandbox Code Playgroud)

以及以下代码

     function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
    $ipaddress = getenv('HTTP_CLIENT_IP');
elseif(getenv('HTTP_X_FORWARDED_FOR'))
    $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
elseif(getenv('HTTP_X_FORWARDED'))
    $ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
    $ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
    $ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
    $ipaddress = getenv('REMOTE_ADDR');
else
    $ipaddress = 'UNKNOWN';

return $ipaddress;  } echo get_client_ip();  
Run Code Online (Sandbox Code Playgroud)

但是两个代码都显示了这个结果 ::1

plzzzzz帮帮我的朋友们!如何获取远程IP地址?

php ip-address magento

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

如何在Magento中获得有效的主题名称

我在Magento网站上工作,找不到找到当前活动主题信息的方法。请提出一种在Magento平台上获取当前活动主题信息的方法。我正在使用Magento 1.7.0.2版本

谢谢你的帮助。

magento magento-1.7

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

标签 统计

magento ×10

php ×4

magento-1.7 ×3

base-url ×1

filter ×1

flat ×1

ip-address ×1

magento-1.6 ×1

regex ×1

wordpress ×1