fishingboy/madump
Composer 安装命令:
composer require fishingboy/madump
包简介
Magento Data Object Dump Tool
关键字:
README 文档
README
English | 繁體中文
Why MaDump?
Calling var_dump() or print_r() on a Magento object causes an out-of-memory error because of deeply nested circular references. MaDump dumps only the first level of an object, giving you just enough information to navigate the code during development.
Installation
composer require fishingboy/madump
Usage
-
Print directly
use Fishingboy\MaDump\MaDump; MaDump::dump($product);
Output:
<pre> Magento\Catalog\Model\Product\Interceptor ->addAttributeUpdate($code, $value, $store) ->addCustomOption($code, $value, $product) ->addData(array $arr) ->addImageToMediaGallery($file, $mediaAttribute, $move, $exclude) ->addOption(Magento\Catalog\Model\Product\Option $option) ->afterCommitCallback() ->afterDelete() ->afterDeleteCommit() ->formatUrlKey($str) ->fromArray(array $data) ->getAttributeDefaultValue($attributeCode) ->getAttributeSetId() : 16 (string) ->getAttributeText($attributeCode) ->getAttributes($groupId, $skipSuper) ->getAvailableInCategories() : array ->getCacheIdTags() : array ->getCacheTags() : array ->getCalculatedFinalPrice() : (NULL) ->getCategory() : (NULL) ->getCategoryCollection() : Magento\Catalog\Model\ResourceModel\Category\Collection\Interceptor ... </pre>
-
Capture as a string (for logging)
use Fishingboy\MaDump\MaDump; $product_dump = MaDump::dump($product, true); $this->_logger->info("product => " . $product_dump);
-
Stop execution after dumping
use Fishingboy\MaDump\MaDump; MaDump::dump($product); exit;
-
Typical trace workflow
Step 1 — dump the top-level object:
MaDump::dump($product);
Step 2 — drill into an attribute:
MaDump::dump($product->getCustomAttributes());
Step 3 — drill further:
MaDump::dump($product->getCustomAttributes()[0]);
Keep going level by level until you find what you need.
Output Format
-
Object
<pre> Magento\Catalog\Model\Product\Interceptor ->addAttributeUpdate($code, $value, $store) ->addCustomOption($code, $value, $product) ->addData(array $arr) ->addImageToMediaGallery($file, $mediaAttribute, $move, $exclude) ->addOption(Magento\Catalog\Model\Product\Option $option) ->afterCommitCallback() ->afterDelete() ->afterDeleteCommit() ->formatUrlKey($str) ->fromArray(array $data) ->getAttributeDefaultValue($attributeCode) ->getAttributeSetId() : 16 (string) ->getAttributeText($attributeCode) ->getAttributes($groupId, $skipSuper) ->getAvailableInCategories() : array ->getCacheIdTags() : array ->getCacheTags() : array ->getCalculatedFinalPrice() : (NULL) ->getCategory() : (NULL) ->getCategoryCollection() : Magento\Catalog\Model\ResourceModel\Category\Collection\Interceptor ... </pre>
Zero-argument getter methods are called automatically and their return values are shown inline:
->getAttributeSetId() : 16 (string) ->getCategoryCollection() : Magento\Catalog\Model\ResourceModel\Category\Collection\Interceptor ->getCacheIdTags() : array
-
Array
<pre> Array(52) => [0] => (Magento\Framework\Api\AttributeValue) [10] => (Magento\Framework\Api\AttributeValue) [11] => (Magento\Framework\Api\AttributeValue) [12] => (Magento\Framework\Api\AttributeValue) ... </pre>
Or for a simple array:
<pre> Array(2) => [0] => 101 [1] => 102 </pre>
-
Scalar value
<pre>1 (integer)</pre>
<pre>true (boolean)</pre>
<pre>sku-123 (string)</pre>
License
This project is licensed under the MIT License.
统计信息
- 总下载量: 55
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-09-09