Magentoストアから製品のリストを取得しようとしていますが、製品あたり3つの属性しかロードされていないため、製品全体をロードする。さて、私はそれを正しくやっていないか、上記を前提として間違っています。ここに私のスクリプトです:Magento:プログラムのリストをプログラムで取得する
<?php
$script_start = microtime(true);
// Load Magento core
require_once '../app/Mage.php';
Mage::app();
// Load products :: collection
$query_create_start = microtime(true);
$prod_catalog = Mage::getModel("catalog/product")->getCollection()->
addAttributeToSelect('sku')->
addAttributeToSelect('name')->
addAttributeToSelect('category_ids');
$query_create_end = microtime(true);
$query_create_time = $query_create_end - $query_create_start;
echo "Query creation took $query_create_time seconds.<br>";
$product_loop_start = microtime(true);
foreach($prod_catalog as $product) {
var_dump($product);
$one_product_loop = microtime(true);
$one_product_time = $one_product_loop - $product_loop_start;
echo "Getting one product took $one_product_time seconds.<";
die('done');
}
$product_loop_end = microtime(true);
?>
そして、ここで(ダンプ・データなし)出力です:、私は尋ねたよりも、それは多くの属性がロードされていることがわかり、私は、製品のvar_dumpを見てみると、今
Query creation took 0.0043220520019531 seconds.
one product took 32.509027004242 seconds
:
object(Mage_Catalog_Model_Product)#74 (32) {
["_cacheTag":protected]=>
string(15) "catalog_product"
["_eventPrefix":protected]=>
string(15) "catalog_product"
["_eventObject":protected]=>
string(7) "product"
["_canAffectOptions":protected]=>
bool(false)
["_typeInstance":protected]=>
NULL
["_typeInstanceSingleton":protected]=>
NULL
["_linkInstance":protected]=>
NULL
["_customOptions":protected]=>
array(0) {
}
["_urlModel":protected]=>
NULL
["_errors":protected]=>
array(0) {
}
["_optionInstance":protected]=>
NULL
["_options":protected]=>
array(0) {
}
["_reservedAttributes":protected]=>
NULL
["_isDuplicable":protected]=>
bool(true)
["_calculatePrice":protected]=>
bool(true)
["_defaultValues":protected]=>
array(0) {
}
["_storeValuesFlags":protected]=>
array(0) {
}
["_lockedAttributes":protected]=>
array(0) {
}
["_isDeleteable":protected]=>
bool(true)
["_isReadonly":protected]=>
bool(false)
["_resourceName":protected]=>
string(15) "catalog/product"
["_resource":protected]=>
NULL
["_resourceCollectionName":protected]=>
string(26) "catalog/product_collection"
["_dataSaveAllowed":protected]=>
bool(true)
["_isObjectNew":protected]=>
NULL
["_data":protected]=>
array(12) {
["entity_id"]=>
string(1) "7"
["entity_type_id"]=>
string(1) "4"
["attribute_set_id"]=>
string(1) "4"
["type_id"]=>
string(6) "simple"
["sku"]=>
string(10) "1000000000"
["has_options"]=>
string(1) "0"
["required_options"]=>
string(1) "0"
["created_at"]=>
string(19) "2016-07-11 11:05:03"
["updated_at"]=>
string(19) "2017-03-03 21:14:21"
["name"]=>
string(62) "My simple product"
["is_salable"]=>
string(1) "1"
["stock_item"]=>
object(Varien_Object)#49 (7) {
["_data":protected]=>
array(1) {
["is_in_stock"]=>
string(1) "1"
}
["_hasDataChanges":protected]=>
bool(false)
["_origData":protected]=>
NULL
["_idFieldName":protected]=>
NULL
["_isDeleted":protected]=>
bool(false)
["_oldFieldsMap":protected]=>
array(0) {
}
["_syncFieldsMap":protected]=>
array(0) {
}
}
}
["_hasDataChanges":protected]=>
bool(true)
["_origData":protected]=>
NULL
["_idFieldName":protected]=>
string(9) "entity_id"
["_isDeleted":protected]=>
bool(false)
["_oldFieldsMap":protected]=>
array(0) {
}
["_syncFieldsMap":protected]=>
array(0) {
}
}
いいえ私はフラットテーブルを使用していません。私がそうだった場合、addAttributeToSelect()はフラットでは機能しないため、エラーが発生します。 – Milos