【问题标题】:Magento : Get product URL In Export CSVMagento:在导出 CSV 中获取产品 URL
【发布时间】:2013-02-13 06:05:31
【问题描述】:

在 magento 中,我如何在我的产品导出 CSV 中获取产品完整 url,即 SITE_URL/PRODUCT URL 我在谷歌上搜索这些东西,但找不到与此相关的任何东西......

我还挖掘了法师 app/code/core/Mage/ImportExport/Model/Export/Entity 并编辑以下文件 Product.php 但可以找到 URL_PATH 列以包含完整路径

【问题讨论】:

    标签: php magento magento-1.7


    【解决方案1】:

    好吧,我自己在这里找到了解决方案 我想在 url_path 列下添加产品的完整 url 路径
    1) 编辑路径 app/code/core/Mage/ImportExport/Model/Export/Entity 的文件
    2) 在第 630 行

     foreach ($validAttrCodes as &$attrCode) { // go through all valid attribute codes
    

    3) 这是为导出提供所有属性
    4) 我插入了一个条件

    if($attrCode=='url_path'){
                                $attrValue = str_replace('index.php/','',Mage::getBaseUrl()).$attrValue;
                            }
    


    5)测试我的出口,一切都很好
    最后我知道我破解了代码,但我没有足够的时间来编写模块,甚至我也不知道如何...... :-)

    【讨论】:

    • 你可以用Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)代替str_replace
    【解决方案2】:

    我是这样做的:

                // Gets the current store's id
                $store = Mage::app()->getDefaultStoreView();
                $product->setStoreId($store->getStoreId());
    
                //prepare csv contents
                $data = array();
                $data[] = $product['sku'];
                // this is the URL:
                $data[] = $product->getProductUrl();
    

    【讨论】:

      【解决方案3】:

      您好,在 csv 中您无法获取站点 URL,因为在磁电机中,它会自动将站点 URL 与目录路径连接起来。你能告诉我为什么你需要csv中的网站网址

      【讨论】:

      • 这是我的客户要求,他需要完整的 URl
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-09
      • 2015-12-23
      • 2017-03-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多