magento addAttributeToFilter 的方法和AND OR使用

文章整理来自网络,主要参考有:

http://fishpig.co.uk/magento/tutorials/addattributetofilter/

http://stackoverflow.com/questions/5301231/addattributetofilter-and-or-condition-in-magentos-collection


主要的句子

$_products = Mage::getResourceModel('catalog/product_collection')
   ->addAttributeToSelect(array('name', 'product_url', 'small_image'))
   ->addAttributeToFilter('sku', array('like' => 'UX%'))
    ->load();

 

addAttributeToSelect没什么要说的,只要筛选正确的数据表有的字段就可以

 

eq的两种写法写法

$_products->addAttributeToFilter('status', array('eq' => 1)); // Using the operator
$_products->addAttributeToFilter('status', 1); // Without using the operator

如果上面有不同的筛选,就相当于AND了,OR的写法:

// OR QUERY

$collection->addAttributeToFilter(array(

array(

'attribute' => 'sku','like' => '%ch%'),

array(

'attribute' => 'status','eq' => '1')

));

 

noequal

$_products->addAttributeToFilter('sku', array('neq' => 'test-product'));

 

$_products->addAttributeToFilter('sku', array('like' => 'UX%'));//like

 

$_products->addAttributeToFilter('sku', array('nlike' => 'err-prod%'));//nolike

 

$_products->addAttributeToFilter('id', array('in' => array(1,4,98)));//in

 

$_products->addAttributeToFilter('id', array('nin' => array(1,4,98))); //not in

 

$_products->addAttributeToFilter('description', array('null' => true));  //null

 

$_products->addAttributeToFilter('description', array('notnull' => true)); //not mull

 

$_products->addAttributeToFilter('id', array('gt' => 5));//Greater Than - gt

 

$_products->addAttributeToFilter('id', array('lt' => 5)); //Less Than - lt

 

$_products->addAttributeToFilter('id', array('gteq' => 5)); //Greater Than or Equals To- gteq

 

$_products->addAttributeToFilter('id', array('lteq' => 5)); //Less Than or Equals To - lteq

 

排错方法

// Method 1
Mage::getResourceModel('catalog/product_collection')->load(true);

// Method 2
$collection = Mage::getResourceModel('catalog/product_collection')

echo $collection->getSelect();

 

 

Excel包含文件提示:‘隐含模块中的编译错误’或者无法保存

我的文件格式是xlsm包含宏的文件,以前都正常使用,放到别人的机器也是正常使用。

甚至,我重装office都没有效果。

网上搜索一大堆,有一个网友提醒了,他是在删除了暴风影音之后出现问题,重新安装之后就可以了。

这个提醒了我,应该删除某些软件修改了,windows的核心文件,当时删除的时候,360安全卫士也有提醒。

解决办法:

1.安装最近卸载的软件试试。

2.尝试安装我提供的ocx空间文件。(我的问题是安装后可以使用的)

3.带添加

 

ps.删除软件,最好按照360的保护来做

ps2.提供了来自互联网的wps的宏安装办法。

 

下载连接:

 OCX-office

 wps安装宏

mysql语句根据sku 查询magento的产品名

答案来自http://stackoverflow.com/questions/5323102/magento-products-import-from-database-using-sql-query

第一步,找出各个属性对应的attribute_code

select attribute_code, attribute_id, backend_type from eav_attribute
    where entity_type_id = (select entity_type_id from eav_entity_type where entity_type_code = 'catalog_product')
      and attribute_code in ('name', 'url_path', 'price', 'image', 'description', 'manufacturer');

一般结果为

+----------------+--------------+--------------+
| attribute_code | attribute_id | backend_type |
+----------------+--------------+--------------+
| description    |           61 | text         |
| image          |           74 | varchar      |
| manufacturer   |           70 | int          |
| name           |           60 | varchar      |
| price          |           64 | decimal      |
| url_path       |           87 | varchar      |
+----------------+--------------+--------------+

对应的name是60

第二步

select p.sku, p.entity_id, n.value name
    from catalog_product_entity p
    join catalog_product_entity_varchar n on n.entity_id = p.entity_id
  where n.attribute_id = 60 AND p.sku='001-C';

可以得出结果了,其他属性自己添加查询

再次感谢Joseph Mastey的回答

 

magento bundle product backend tier price 组合产品的分组价格

magento在后台显示bundle的产品时,是按照Percent Discount的折扣率显示的,不能直接显示bundle的分组价格具体是多少

主要改动文件有两个

\app\code\local\Mage\Bundle\Model\Product\Price.php

搜索  / 100

line 618

 // $tierPrice = $finalPrice – ($finalPrice * ($tierPrice / 100));
            $tierPrice = $tierPrice;

如果也要修改group的话,自己对应修改

第二个,去掉数据验证

1). 1.7的版本以上的

app\code\local\Mage\Core\etc\jstranslator.xml

line 165

  <!–   <validate-percents translate="message" module="core">
        <message>Please enter a number lower than 100.</message>
    </validate-percents>
    –>

2) 1.5的版本的js位置是 \js\prototype\validation.js line 717 这个拿掉全局的Js关于百分比的验证

建议的做法是 app\code\core\Mage\Bundle\Block\Adminhtml\Catalog\Product\Edit\Tab\Attributes.php line 96~97

                    //->setPriceColumnHeader(Mage::helper('bundle')->__('Percent Discount'))
                    ->setPriceColumnHeader(Mage::helper('bundle')->__('Price'))
                    //->setPriceValidation('validate-greater-than-zero validate-percents')

去掉验证,又可以改名字

第三,其他一些文件,比如对应前台主题文件需要修改,不然就会

Buy 1 with 300% discount each

Buy 2 with 200% discount each

暂时就是这样,转载记得署名出处

Sears 通过XML 查看处理进程报告(processing report)

 

https://www.searscommerceservices.com/question/xml-how-do-i-view-my-processing-report/

 processing report 包括上传更新文件的状态报告,每个上传的文件都会生成一个处理报告。

 

XSD:  https://seller.marketplace.sears.com/SellerPortal/s/schema/shared/seller-error-report-v1.xsd

Sample:  https://seller.marketplace.sears.com/SellerPortal/s/schema/samples/seller-error-report-v1-example.xml

Sears 通过XML 创建产品条目(create an item)

https://www.searscommerceservices.com/question/xml-how-do-i-create-an-item/

Sears不会不定期的更新每个xml规格的标准,现在状况如下(2015年5月18日 10:37:26):

 FBM  v18;FBS  V5;DDS V3

 

1).FBM

PUT URL:  https://seller.marketplace.sears.com/SellerPortal/api/catalog/fbm/v18?email={emailaddress}&password={password}

XSD:  https://seller.marketplace.sears.com/SellerPortal/s/schema/rest/catalog/import/v18/lmp-item.xsd

Sample:  https://seller.marketplace.sears.com/SellerPortal/s/schema/samples/rest/catalog/import/v18/lmp-item.xml

 

2).FBS

PUT URL:  https://seller.marketplace.sears.com/SellerPortal/api/catalog/fbs/v5?email={}&password={}

XSD:  https://seller.marketplace.sears.com/SellerPortal/s/schema/rest/catalog/import/v5/fbs-item.xsd

Sample:  https://seller.marketplace.sears.com/SellerPortal/s/schema/samples/rest/catalog/import/v5/fbs-item.xml

 

3).DDS

PUT URL:  https://seller.marketplace.sears.com/SellerPortal/api/catalog/dss/v3?email={emailaddress}&password={password}

XSD:  https://seller.marketplace.sears.com/SellerPortal/s/schema/rest/catalog/import/v3/dss-item.xsd

Sample:  https://seller.marketplace.sears.com/SellerPortal/s/schema/samples/rest/catalog/import/v3/dss-item.xml

 

 

 

Sears xml的字段定义

https://seller.marketplace.sears.com/SellerPortal/d/help/product_data_definitions.jsp

 

Field Description Validations Sell On Sears Program Fulfilled by Sears Program Example
Item Id This is a unique identifier for a product. Once created, please don't change it. 50 characters for Sell on Sears (FBM) and 20 characters for Sell through Sears (FBS), numbers, letters (case sensitive), spaces (if applicable), dashes only. Required Required A67892
Action Flag Use this column to indicate changes to this item. Mark with a "D" to delete Optional Optional D
FBS Item Enter "Yes" or "No" to designate Fulfilled By Sears items. Marking an existing Fulfilled by Merchant item “Yes” will convert it to a Fulfilled By Sears item. Allowable Values: Yes or No N/A Required Yes
Variation Group ID If you have an item that contains variations, you have to option to enter an alphanumeric group id to associate them together in your inventory. 20 characters max, alphanumeric Conditional Conditional RedTies30
Title Enter a product name. 128 characters max. To avoid errors, do not include HTML tags or any special characters (ex. * $ & +) Required Required Sony 7 in. Digital Photo Frame
Short Description Provide a short description of the product. Limited HTML is allowed, please see http://searscommerceservices.com/question/Is-HTML-supported-for-product-content For more information Required Required Keep a slideshow of your favorite memories and faces close at hand with this digital photo frame from Sony. Place it on a table, bookshelf, nightstand, or anywhere else you wish to see your digital pictures. Includes AC adapter and remote control.
Long Description This field represents the long product description which will be displayed on the product page. 5000 characters max. To avoid errors, do not include HTML tags or any special characters (ex. * $ & +) Optional Optional Keep a slideshow of your favorite memories and faces close at hand with this digital photo frame from Sony. Place it on a table, bookshelf, nightstand, or anywhere else you wish to see your digital pictures. Includes AC adapter and remote control.

 

– 7 in. Digital Photo Frame with 800 x 480 Resolution, 15:9 Aspect Ratio LCD Screen.
– 256MB of Internal Memory with optional image resizing to maximize Internal Memory.
– Multiple Display modes, including nine slideshow styles, clock and calendar modes, and single image and index views.
– Supports most memory card formats and is equipped with a USB B-type connection.
– Decodes and displays up to 48-megapixel and 100MB images, including JPEG and RAW (preview only: SRF, SR2, ARW).
– Auto image rotation and the auto orientation sensor will detect whether the frame is sitting horizontally or vertically and automatically rotate images.
– The backlit Sony® logo can be switched on/off.

Seller Categories You may provide your own categorization (categorization on your website) of the item in the form of level 1-level 2-level 3. This information will be used to generate better categorization recommendations for this item. This categorization DOES NOT need to align with current categories in the Sears Tag Catalog. 100 characters max. Optional Optional ComputersElectronics-Televisions-FlatPanel
Packing Slip Description This short description should accurately express a product’s longer title. It will be used to locate this product in our warehouse and will be printed on the packing slip when an order is shipped. 30 characters max, alphanumeric, no special characters (ex. * $ & +) N/A Required Product Title: Blue 60GB HDD Camcorder with 2.7" LCD and Three 1-Touch Upload Modes

 

Packing Slip Description: BL 60GBCamcorder2.7”LCD

UPC Enter the 12-digit Universal Product Number (UPC) or 13-digit European Article Number (EAN) including any leading zeros. Don’t remove or insert any characters or spaces. Once it’s entered, please don't change it. Only valid 12-digit UPC or 13-digit EAN numeric values will process correctly Optional Optional 296666461012 or 059295041567
Manufacturer Model # This is the unique identifying number assigned to a product by the manufacturer. 40 characters max, letters, number, dash, underscores only Required Required DPF-V70
Cost Enter the cost of a single unit, excluding tax or shipping fees. If necessary, this field will be referenced for insurance purposes. You can enter up to 5 digits before the decimal point and two after. List prices in US dollars, without a $ sign, commas, text, or quotation marks N/A Required 32.25
Standard Price Do not include taxes, shipping costs, rebates, coupons, or bulk discounts. This value must be equal to or greater than the cost. You can enter up to 5 digits before the decimal point and two after. List prices in US dollars, without a $ sign, commas, text, or quotation marks. Minimum Standard Price is 0.02 Required Required 59.95 or 1000.00 (note that you should include the digits to the right of the decimal point)
Sale Price Item is put on sale when sale price is provided and goes off sale when the sale end date is reached. Sale Price must be less than the Standard Price. You can enter up to 5 digits before the decimal point and two after. List prices in US dollars, without a $ sign, commas, text, or quotation marks Optional Optional 59.95 or 1000.00 (note that you should include the digits to the right of the decimal point)
Sale Start Date The date when the item will start being sold at the Sale Price.
NOTE: Required if Sale Price is provided.
Format "MM/DD/YYYY". The Start Date must occur before the End Date. Optional Optional 12/01/2010
Sale End Date The date when an item will stop being sold at the Sale Price.
NOTE: Required if Sale Price is provided.
Format "MM/DD/YYYY". The End Date must occur after the Start Date. Required if you've entered a Sale Price Required if you've entered a Sale Price 12/01/2010
Promotional Text This is the text that customers will see describing the details of this sale. 50 characters max, numbers, letters, $, !, % only.. Symbols can't be doubled up (ex. Sale!!) Optional Optional 10% Off All Shoes
Shipping Override If this product has free shipping, add $0.00 here. 0.00 is the only value accepted in this column Optional N/A 0.00
Shipping Override Start Date The date when an item will have free shipping. If provided, this value must be in the format "MM/DD/YYYY" and be at least 2 days after the current date. The Start Date must occur before the End Date. Format "MM/DD/YYYY". The date must be at least 2 days after the current date. The Start Date must occur before the End Date. Optional N/A 12/03/2009
Shipping Override End Date The date when an item’s free shipping ends. If provided, this value must be in the format "MM/DD/YYYY" and be at least 2 days after the current date. The End Date must occur after the Start Date. Format "MM/DD/YYYY". The date must be at least 2 days after the current date. The End Date must occur after the Start Date. Optional N/A 12/04/2009
Free Shipping Promotional Text This is the text that customers will see describing the details of this free shipping promotion. 50 characters max, numbers, letters, $, !, % only.. Symbols can't be doubled up (ex. Sale!!) Optional N/A Free Shipping on all handbags until 12/31/2011
Low Inventory Alert If you’d like to receive an alert when an item’s inventory reaches a certain threshold, enter that number in this field. If this field is left blank, it will default to a quantity of 10. Enter a value greater than or equal to zero Optional Optional 5
MAP Price Indicator This identifies the Standard Price as also being the Minimum Advertised Price(MAP). Specify as "Strict" or "Non-Strict" Optional Optional Strict
Brand Name Specify the brand for your product.
Note: Used to create a search item attribute, submitting an incorrect or missing brand name will prevent the item from showing up in search results.
254 character max Required Required SONY
Shipping Length Indicates the length of the package in which items will be shipped. Max length is 108". Value must be greater than 0. You can enter up to 6 digits before the decimal point and two after. List prices in US inches without a " sign, commas, text, or quotation marks. Required Required 32.25
Shipping Width Indicates the width of the package in which items will be shipped. Max length is 108". Value must be greater than 0. You can enter up to 6 digits before the decimal point and two after. List prices in US inches without a " sign, commas, text, or quotation marks Required Required 32.25
Shipping Height Indicates the height of the package in which items will be shipped. Max length is 108". Value must be greater than 0. You can enter up to 6 digits before the decimal point and two after. List prices in US inches without a " sign, commas, text, or quotation marks Required Required 32.25
Shipping Weight Indicates the weight of the package in which items will be shipped. Max weight is 130 lbs. Value must be greater than 0. Enter whole lbs only – no ounces. List prices in US lbs without commas, text, or quotation marks Required Required 32.25
Shipping Restrictions Indicates state(s) (USPS Postal State Abbreviation) where you cannot sell/ship the item. Multiple state codes should be separated with comma and no spacesEnter abbreviations from the list below this table Optional Optional MI
Shipping Cost Ground Indicates the amount that should be charged to the customer for a Ground shipment (5-7 days transit time). You can enter up to 5 digits before the decimal point and two after. Leave empty to default to weight based rate configuration at Account level. Put "NA" to exclude this shipping method for the item. Optional N/A 6.25
Shipping Cost 2 day Indicates the amount that should be charged to the customer for a 2 day shipment. You can enter up to 5 digits before the decimal point and two after. Leave empty to default to weight based rate configuration at Account level. Put "NA" to exclude this shipping method for the item. Optional N/A NA
Shipping Cost Next Day Indicates the amount that should be charged to the customer for a Next Day shipment. You can enter up to 5 digits before the decimal point and two after. Leave empty to default to weight based rate configuration at Account level. Put "NA" to exclude this shipping method for the item. Optional N/A NA
Choking Hazard: small parts Indicator identifying if the item has potential choking hazard Enter "Y" or "N" Optional Optional N
Choking Hazard: balloons Indicator identifying if the item has potential choking hazard Enter "Y" or "N" Optional Optional N
Choking Hazard: small ball Indicator identifying if the item has potential choking hazard Enter "Y" or "N" Optional Optional N
Choking Hazard: contains small ball Indicator identifying if the item has potential choking hazard Enter "Y" or "N" Optional Optional N
Choking Hazard: contains marble Indicator identifying if the item has potential choking hazard Enter "Y" or "N" Optional Optional N
Choking Hazard: other Indicator identifying if the item has potential choking hazard Enter "Y" or "N" Optional Optional N
Safety Warning: other Indicator identifying if the item has any other potential safety hazards Enter "Y" or "N" Optional Optional N
No Warning Indicator identifying if the item has potential choking hazard Enter "Y" or "N" Optional Optional N
Energy Star Compliant Indicator identifying if the item is Energy Star Compliant. Enter "Y" or "N" Optional Optional N
Good HouseKeeping Indicator identifying if the item has Good Housekeeping – Seal of Approval. Enter "Y" or "N" Optional Optional N
Hazardous Material Indicator identifying if the item has any Hazardous Material Enter "Y" or "N" Optional Required N
Restricted Product Fulfilled By Sears restricts certain products. Use this field to designate restricted items. The following items are considered restricted: Liquids; Aerosol; Weapons/ Firearms/ Ammunition; Tobacco Product; Pesticide; Foodstuff/ Consumables/ Perishable goods; Live Plants or Animals; Used Items; Drugs. Enter "Y" or "N" N/A Required N
California Emissions Indicator identifying if the item must be compliant with California Emission standards. Enter "Y" or "N" Optional Optional N
Web Exclusive Indicator identifying if the item can only purchased exclusively online and is not sold in stores. Enter "Y" or "N" Optional Optional N
Food Item Indicator identifying if the item is food. Enter "Y" or "N" Required Required N
Requires Refrigeration Indicator identifying if the item requires refrigeration. Enter "Y" or "N" Required Required N
Frozen Item Indicator identifying if the item is frozen. Enter "Y" or "N" Required Required N
Alcohol Indicator identifying if the item is alocohol. Enter "Y" or "N" Required Required N
Tobacco Indicator identifying if the item is tobacco. Enter "Y" or "N" Required Required N
Product Image URL Image URL for the primary image of the item. Image should be hosted and URL provided is the link to that image. Must have a valid image URL that contains an image extention (ex. .jpg, .gif, .png, etc.). Recommended size 501 x 501 pixles. Maximum 1900 x 1900 picels. Square aspect ratio. Required Required http://www.companyname.com/products/item.jpeg
Mature content TDB. Enter "Y" or "N" Optional Optional N
Swatch Image URL Items with variations must have a valid image URL and one swatch for each color variation offered. Only enter one URL per line item. Must have a valid image URL that contains an image extention (ex. .jpg, .gif, .png, etc.) Optional Optional http://www.companyname.com/products/swatch.jpeg
Feature Image URL #1 Image URL for any additional feature image(s). Image(s) should be hosted and URL provided is the link to the image(s). Must have a valid image URL that contains an image extention (ex. .jpg, .gif, .png, etc.) Optional Optional http://www.companyname.com/products/item.jpeg
Feature Image URL #2 Image URL for any additional feature image(s). Image(s) should be hosted and URL provided is the link to the image(s). Must have a valid image URL that contains an image extention (ex. .jpg, .gif, .png, etc.) Optional Optional http://www.companyname.com/products/item.jpeg
Feature Image URL #3 Image URL for any additional feature image(s). Image(s) should be hosted and URL provided is the link to the image(s). Must have a valid image URL that contains an image extention (ex. .jpg, .gif, .png, etc.) Optional Optional http://www.companyname.com/products/item.jpeg
Feature Image URL #4 Image URL for any additional feature image(s). Image(s) should be hosted and URL provided is the link to the image(s). Must have a valid image URL that contains an image extention (ex. .jpg, .gif, .png, etc.) Optional Optional http://www.companyname.com/products/item.jpeg
Feature Image URL #5 Image URL for any additional feature image(s). Image(s) should be hosted and URL provided is the link to the image(s). Must have a valid image URL that contains an image extention (ex. .jpg, .gif, .png, etc.) Optional Optional http://www.companyname.com/products/item.jpeg
Feature Image URL #6 Image URL for any additional feature image(s). Image(s) should be hosted and URL provided is the link to the image(s). Must have a valid image URL that contains an image extention (ex. .jpg, .gif, .png, etc.) Optional Optional http://www.companyname.com/products/item.jpeg
Important Attributes Specify all applicable keywords/attributes for the product. You’ll need to reference the "Attributes" tab for allowable attributes and values. At least one attribute is required for variation items. Must have unique Item ID, UPC and variant item attributes (ex. you can't have two items in the same group that are both color: purple, size: extra-small and fit: slim) Required Required  
Attributes Specify all applicable keywords/attributes for the product. You’ll need to reference the "Attributes" tab for allowable attributes and values. At least one attribute is required for variation items. Must have unique Item ID, UPC and variant item attributes (ex. you can't have two items in the same group that are both color: purple, size: extra-small and fit: slim) Optional Optional  

 

State Abbreviations

 

AA – ARMED FORCES AMERICAS AE – ARMED FORCES AFRICA AK – ALASKA AL – ALABAMA AP – ARMED FORCES PACIFIC
AR – ARKANSAS AS – AMERICAN SAMOA AZ – ARIZONA CA – CALIFORNIA CO – COLORADO
CT – CONNECTICUT DC – DISTRICT OF COLUMBIA DE – DELAWARE FL – FLORIDA GA – GEORGIA
GU – GUAM HI – HAWAII IA – IOWA ID – IDAHO IL – ILLINOIS
IN – INDIANA KS – KANSAS KY – KENTUCKY LA – LOUISIANA MD – MARYLAND
ME – MAINE MA – MASSACHUSETTS MI – MICHIGAN MN – MINNESOTA MO – MISSOURI
MP – NORTHERN MARIANA ISLANDS MS – MISSISSIPPI MT – MONTANA NC – NORTH CAROLINA ND – NORTH DAKOTA
NE – NEBRASKA NH – NEW HAMPSHIRE NJ – NEW JERSEY NM – NEW MEXICO NV – NEVADA
NY – NEW YORK OH – OHIO OK – OKLAHOMA OR – OREGON PA – PENNSYLVANIA
PW – PALAU RI – RHODE ISLAND SC – SOUTH CAROLINA SD – SOUTH DAKOTA TN – TENNESSEE
TX – TEXAS UT – UTAH VA – VIRGINIA VI – VIRGIN ISLANDS VT – VERMONT
WA – WASHINGTON WI – WISCONSIN WV – WEST VIRGINIA WY – WYOMING  

Sears 通过XML 下载库存状况

https://www.searscommerceservices.com/question/xml-how-do-i-download-inventory-levels/

Sears库存包括:已有库存(On-Hand Inventory),保留数量(reserved Inventory),可销售库存(Available Inventory

全局XML:

https://seller.marketplace.sears.com/SellerPortal/api/inventory/v5?email={emailaddres}&password={password}

基于产品id(Sears的)

 https://seller.marketplace.sears.com/SellerPortal/api/inventory/v5?itemIds={itemids}&email={emailaddress}&password={password}

基于货物仓位( location id:

https://seller.marketplace.sears.com/SellerPortal/api/inventory/v5?locationId={locationid}&email={emailaddress}&password={password}

基于id和仓位:

 https://seller.marketplace.sears.com/SellerPortal/api/inventory/v5?itemIds={itemids}&locationId={locationid}&email={emailaddress}&password={password}

 

xml定义文件和demo

XSD: https://seller.marketplace.sears.com/SellerPortal/s/schema/rest/inventory/export/v5/item-inventory-public.xsd?view=markup

Sample XML: https://seller.marketplace.sears.com/SellerPortal/s/schema/samples/rest/inventory/export/v5/item-inventory-public.xml?view=markup

 

Sears 通过XML 进行价格(price changes)更新

来源:

https://www.searscommerceservices.com/question/xml-how-do-i-submit-price-changes/

主要的xml put地址:

PUT URL:  https://seller.marketplace.sears.com/SellerPortal/api/pricing/fbm/v5?email={emailaddress}&password={password}

 

定义文件和演示xml,现在最新是V5版,而且FBM格式

 

Version 4:
XSD:  https://seller.marketplace.sears.com/SellerPortal/s/schema/rest/pricing/import/v5/pricing.xsd