简体   繁体   English

Magento:在导出 CSV 中获取产品 URL

[英]Magento : Get product URL In Export CSV

In magento how can i get product full url ie SITE_URL/PRODUCT URL in my product export CSV I was googling for this stuff but can't find anything related to this....在 magento 中,如何在我的产品导出 CSV 中获取产品完整网址,即 SITE_URL/PRODUCT URL 我在谷歌上搜索这些东西,但找不到与此相关的任何内容....

i aslo dig the mage app/code/core/Mage/ImportExport/Model/Export/Entity and edit the follwing file Product.php but can find the URL_PATH colum to include the full path我还挖掘法师应用程序/代码/核心/法师/ImportExport/Model/Export/Entity 并编辑以下文件 Product.php 但可以找到 URL_PATH 列以包含完整路径

Well found it my self here is the solution I want to add the full url path to the product under the url_path column很好,我自己在这里找到了解决方案,我想在 url_path 列下添加产品的完整 url 路径
1) Edit the file at path app/code/core/Mage/ImportExport/Model/Export/Entity 1) 在路径 app/code/core/Mage/ImportExport/Model/Export/Entity 编辑文件
2) At line number 630 2) 在第 630 行

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

3) this is giving all attributes to export 3)这是给所有属性导出
4) I inserted a condition 4)我插入了一个条件

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


5) Test my export and all was fine 5)测试我的出口,一切都很好
At the end i know i hack the code but i don't have enough time to code the module nor even i know how to ... :-)最后,我知道我破解了代码,但我没有足够的时间来编写模块代码,甚至我也不知道如何... :-)

I did it like this:我是这样做的:

            // 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();

Hi in csv you cant get the site URL, because in magneto it automatically concatenates the site URL with the directory path.您好,在 csv 中您无法获取站点 URL,因为在 Magneto 中,它会自动将站点 URL 与目录路径连接起来。 Can you please tell me why you need the site url in csv你能告诉我为什么你需要 csv 中的站点 url

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM