让magento后台删除产品时同时删除产品图片

原本的magento程序在删除一个产品的时候是不会把产品相关的图片也删除。这样造成两个问题

一是:这样长时间下来,会导致空间里有太多的没用的产品图片,占用太多资源。
二是:在批量倒入时,如果产品图片库有有新倒入的产品图片,造成新倒入的产品图片会更名,造成一个产品多个一样的图片

解决办法(代码是别人写的):

将app/code/core/Mage/Catalog/Model/Product.php
拷到
app/code/local/Mage/Catalog/Model/Product.php
然后在delete函数中的第一行加入以下代码:

foreach ($this->getMediaGallery(‘images’) as $image){

$image_path = $this->getMediaConfig()->getMediaPath($image[‘file’]);
if(file_exists($image_path)){
@unlink($image_path);
}
}
问题即可解决

用C#通过ebay api的GetOrders获取订单的示范代码

关天getorders的功能的官方说明

http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetOrders.html

web的引用地址:http://developer.ebay.com/webservices/latest/eBaySvc.wsdl

另外一个vb.net的getorders示范代码https://ebay.custhelp.com/app/answers/detail/a_id/505/~/getorders-sample-in-vb.net-using-ebay-sdk-v459.0-for-.net

using eBay.Service.Call;
using eBay.Service.Core.Sdk;
using eBay.Service.Util;
using eBay.Service.Core.Soap;

namespace Trading_Samples
{
public class OrderManagement
{
//GetOrders
private void GetOrders()
{
//create the context
ApiContext context = new ApiContext();

//set the User token
context.ApiCredential.eBayToken = “Your token”;

//set the server url
context.SoapApiServerUrl = “https://api.sandbox.ebay.com/wsapi”;

//enable logging
context.ApiLogManager = new ApiLogManager();
context.ApiLogManager.ApiLoggerList.Add(new FileLogger(“log.txt”, true, true, true));
context.ApiLogManager.EnableLogging = true;

//set the version
context.Version = “705”;
context.Site = SiteCodeType.UK;
bool blnHasMore = true;

DateTime CreateTimeFromPrev, CreateTimeFrom, CreateTimeTo;

GetOrdersCall getOrders = new GetOrdersCall(context);
getOrders.DetailLevelList = new DetailLevelCodeTypeCollection();
getOrders.DetailLevelList.Add(DetailLevelCodeType.ReturnAll);

//CreateTimeTo set to the current time
CreateTimeTo = DateTime.Now.ToUniversalTime();

//Assumption call is made every 15 sec. So CreateTimeFrom of last call was 15 mins
//prior to now
TimeSpan ts1 = new TimeSpan(9000000000);
CreateTimeFromPrev = CreateTimeTo.Subtract(ts1);

//Set the CreateTimeFrom the last time you made the call minus 2 minutes
TimeSpan ts2 = new TimeSpan(1200000000);
CreateTimeFrom = CreateTimeFromPrev.Subtract(ts2);

getOrders.CreateTimeFrom = CreateTimeFrom;
getOrders.CreateTimeTo = CreateTimeTo;

getOrders.Execute();

if (getOrders.ApiResponse.Ack != AckCodeType.Failure)
{
//Check if any orders are returned
if (getOrders.ApiResponse.OrderArray.Count != 0)
{
foreach (OrderType order in getOrders.ApiResponse.OrderArray)
{
//Update your system with the order information.
Console.WriteLine(“Order Number: ” + order.OrderID);
Console.WriteLine(“OrderStatus: ” + order.OrderStatus);
Console.WriteLine(“Order Created On: ” + order.CreatedTime);

//Get Order Details
TransactionTypeCollection orderTrans = order.TransactionArray;

//Order could be comprised of one or more items
foreach (TransactionType transaction in orderTrans)
{
Console.WriteLine(“Order for: ” + transaction.Item.ItemID + “, ” + transaction.Item.SKU + “, ” + transaction.Item.Title);

//If you are listing variation items, you will need to retrieve the variation
//details as chosen by the buyer
if (transaction.Variation.SKU != null)
{
Console.WriteLine(“Variation: ” + transaction.Variation.SKU);
}
Console.WriteLine(“OrderLineItemID: ” + transaction.OrderLineItemID);
Console.WriteLine(“Qty Purchased: ” + transaction.QuantityPurchased);
Console.WriteLine(“Buyer Info: ” + order.BuyerUserID + “, ” + transaction.Buyer.Email);

}

if (order.CheckoutStatus.Status == CompleteStatusCodeType.Complete)
{
//Get Payment Details
Console.WriteLine(“Order Adjustment Amount: ” + order.AdjustmentAmount.Value);
Console.WriteLine(“Order Amount Paid: ” + order.AmountPaid.Value);
Console.WriteLine(“Payment Method: ” + order.CheckoutStatus.PaymentMethod);

ExternalTransactionTypeCollection extTrans = order.ExternalTransaction;

foreach(ExternalTransactionType extTran in extTrans)
{
Console.WriteLine(“External TransactionID: ” + extTran.ExternalTransactionID);
Console.WriteLine(“External Transaction Time: ” + extTran.ExternalTransactionTime);
Console.WriteLine(“Payment/Refund Amount: ” + extTran.PaymentOrRefundAmount.Value);
}

//Get shipping information
ShippingServiceOptionsType shipping;
shipping = order.ShippingServiceSelected;

Console.WriteLine(“Shipping Service Selected: ” + order.ShippingServiceSelected.ShippingService);

//Get Shipping Address – Address subject to change if the buyer has not completed checkout
AddressType address = order.ShippingAddress;

StringBuilder sAdd = new StringBuilder();
sAdd = sAdd.Append(address.Name);
if (address.Street != null && address.Street != “”)
sAdd.Append(“, ” + address.Street);
if (address.Street1 != null && address.Street1 != “”)
sAdd.Append(“, ” + address.Street1);
if (address.Street2 != null && address.Street2 != “”)
sAdd.Append(“, ” + address.Street2);
if (address.CityName != null && address.CityName != “”)
sAdd.Append(“, ” + address.CityName);
if (address.StateOrProvince != null && address.StateOrProvince != “”)
sAdd.Append(“, ” + address.StateOrProvince);
if (address.PostalCode != null && address.PostalCode != “”)
sAdd.Append(“, ” + address.PostalCode);
if (address.CountryName != null && address.CountryName != “”)
sAdd.Append(“, ” + address.CountryName);
if (address.Phone != null && address.Phone != “”)
sAdd.Append(“: Phone” + address.Phone);

Console.WriteLine(“Shipping Address: ” + sAdd);

double salesTax;
//Get the sales tax
if (order.ShippingDetails.SalesTax.SalesTaxAmount == null)
salesTax = 0.00;
else
salesTax = order.ShippingDetails.SalesTax.SalesTaxAmount.Value;

Console.WriteLine(“Sales Tax: ” + salesTax);

if (order.BuyerCheckoutMessage != null)
{
Console.WriteLine(“Buyer Checkout Message: ” + order.BuyerCheckoutMessage);
}

}
Console.WriteLine(“********************************************************”);
}
}
}

}
}
}

ebay的Trading API 705以上的版本,该如何获取订单交易信息

原先您需要通过GetItemTransactionsGetSellerTransactions来获取transaction信息,并将IncludeContainingOrder设置为true来查看是否有合并订单的情况。然后通过OrderID再次调用GetOrders来查看合并后的订单信息。

从Trading API 705版本后,GetOrders被增强了。您将可以跳过呼叫GetItemTransactionsGetSellerTransactions的步骤,直接使用GetOrders来查看近期成交的交易,并同时获取被合并的订单。

例如:获取某段时间内的订单信息:

<GetOrdersRequest xmlns=”urn:ebay:apis:eBLBaseComponents”>

<CreateTimeFrom>2010-12-01T20:34:44.000Z</CreateTimeFrom>

<CreateTimeTo>2011-02-28T20:34:44.000Z</CreateTimeTo>

<OrderRole>Seller</OrderRole>

<RequesterCredentials>

<eBayAuthToken>TOKEN</eBayAuthToken>

</RequesterCredentials>

</GetOrdersRequest>
另外,在返回的response中,增加了OrderLineItemID字段,这个字段由itemID-TransactionID组成,是一个全局唯一的变量。

您可以通过在使用GetOrders时,将该字段传入OrderID来获取某个transaction的详细信息。

例如,获取itemID为110586452612,交易号为631538694001的交易信息:

<GetOrdersRequest xmlns=”urn:ebay:apis:eBLBaseComponents”>

<OrderIDArray>

<OrderID>110586452612-631538694001</OrderID>

</OrderIDArray>

<OrderRole>Seller</OrderRole>

<RequesterCredentials>

<eBayAuthToken>TOKEN</eBayAuthToken>

</RequesterCredentials>

</GetOrdersRequest>

使用eBay API基本步骤介绍

1.注册开发帐号:https://developer.ebay.com/join/Default.aspx

2.选择API类型: eBay有大约6种API 开发语言,例如.net和Java的SDK
http://developer.ebay.com/products/trading/
http://developer.ebay.com/products/overview/api-by-feature/

3.然后是程序开发和Sandbox测试,例如,
3.1 最基本的‘上传商品’的接口定义如下:http://developer.ebay.com/DevZone/XML/docs/WebHelp/wwhelp/wwhimpl/common/html/wwhelp.htm?context=eBay_XML_API&file=ListingItems-.html
3.2 获取买家付款状态和地址信息的接口是GetSellerTransactions:http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetSellerTransactions.html
3.3 标注商品已发货并上传包裹单号的接口是CompleteSale:http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/CompleteSale.html

3.4 可以提供eBay帐单明细 (seller invoce) 的接口是GetAccount
http://developer.ebay.com/DevZone/XML/docs/WebHelp/ManagingUserInfo-Getting_Account_Information.html

4. 另外,根据eBay和PayPal的要求,如果买家通过PayPal付款,那么买家付款状态和地址信息均应以PayPal网站上的为准
获取PayPal买家地址的接口是 PayPal GetTransactionDetailsAPI
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_soap_r_GetTransactionDetails
其中关键参数是:PaymentStatus 和Address Fields

5. 开发过程中,如有API的功能和业务逻辑问题,可通过如下途径寻求解决:
如果是有纯技术问题,需要到开发者论坛:http://developer.ebay.com/community/forums/
如果有重要的紧急事项需要技术支持,可以联系eBay Support Team(收费的):http://developer.ebay.com/support/developersupport/hours/

6. 正式使用时,eBay通过Auth&Auth这个API,从网站上取得卖家帐号的Token,以便开始上传物品:
http://developer.ebay.com/DevZone/XML/docs/WebHelp/GettingTokens-Getting_Tokens_for_Applications_with_Multiple_Users.html
此过程可参考如下中文范例:�0�2http://www.ebay.cn/public/help/auth/howtoAuth.htm

7. 正式上线前2~4周,需要提请eBay对自己所开发的程序进行简单的认证与授权,大约需要3~10个工作日:
http://developer.ebay.com/support/certification/

以上是大致的情况,先做参考。
其他软件开发商,也有利用API而开发相似软件的,例如‘美胜商’:http://www.ebay.cn/pages/jsp/fm/third/tools_mechentrun.jsp
可以把1件商品批量登录到多个eBay网站。

基于eBayAPI,全球有上万名开发者,有数千款eBayAPI软件。请参考:
http://certifiedprovider.ebay.com/CertifiedProviders.html
以及http://cgi6.ebay.com/ws/eBayISAPI.dll?SolutionsDirectory

magento批量定义realter crosess-sell up-sell三种类型商品关联的插件

http://www.magentocommerce.com/magento-connect/WDCA/extension/549/mass-product-relater/
介绍:   相关产品可以增加内页链接,增加seo,但是如果一个一个加,工作量巨大,而且,magento又慢。这个插件可以对推荐、相关商品等进行批量操作,比如同时选中10个产品,通过一次操作让这10个产品互为相关商品。

这样方便多了!

给magento的新增的,最畅销的产品的图片设定额外图形标签插件

先看看效果,magento的新增的,最畅销的产品的图片设定额外图形标签插件

http://www.magentocommerce.com/magento-connect/Mageex/extension/6905/product_ribbon

这个功能可以对三种商品进行标志,不错,有点醒目,但有一个缺点就是不能扩大商品类型以及给每一个商品设定一个独立的标志,那当然这是免费。
有个收费的此类插件,功能更强,可以一个商品一个标签图形和内容!

推荐一个magento可进行货币转换计算的免费插件

magento如果是多币种,可能通过切换当前的币种类别,来查看当前商品指定币种的价格,但还有一个方法,就是这个插件,
这个插件允许用户从一个货币转换为另一种。这个模块支持所有的货币是由Magento后台货币设置支持的,费率由magento后台自带的费率进行计算的。

http://www.magentocommerce.com/magento-connect/jextn_theme/extension/6926/jextn_currencyconverter

引用代码如下:{{block type=”currencyconverter/currencyconverter” name=”currencyconverter” template=”currencyconverter/currencyconverter.phtml”}}
这种小工具很实用,有利于提高用户在网站的停留时间。

magento后台cms树型组织插件

magento后台的cms,目前是以列表形式组织的,一旦内容多了,查找和定位都比较麻烦。
magento官网上有一个cms树型组织的免费插件,大家可以试试。

http://www.magentocommerce.com/magento-connect/jreinke/extension/6090/clever_cmsmagento-community/Clever_CMS



这个,倒是挺实用的!