Hot answers tagged

54

It's similar to Magento 1, but local.xml.sample is located in pub/errors. Just rename local.xml.sample to local.xml within pub/errors directory.


23

Filtering & sorting grid columns I'll mainly talk about filters here, but a lot of it also applies to sorting. Background: How are grid filters added to the grids collection? Grid Filters are applied in Mage_Adminhtml_Block_Widget_Grid::_prepareCollection(). Slightly abbreviated: $filter = $this->getParam($this->getVarNameFilter(), null); if ...


22

First of all, you need to generate a custom module, create the following files: /app/etc/modules/Mycompany_Mymodule.xml /app/design/adminhtml/default/default/layout/mymodule.xml /app/code/local/Mycompany/Mymodule/Block/adminhtml/Mymodule/Grid.php /app/code/local/Mycompany/Mymodule/Block/adminhtml/Mymodule.php /app/code/local/Mycompany/...


14

This is a magento core bug. What happens is, when customers are registered on website, the middle name attribute entity value is not created at the customer_entity_varchar table. The value should be NULL if the middle name is empty. But It will be created when you edit the customer from the admin panel. FIX: Override "app/code/core/Mage/Reports/Model/...


10

By default Magento doesn't support translation out-of-box for error pages, and requires some customizations to allow for such features. So technically there is no proper way to do such. Since the full stack is NOT initialized during error generation, normal translation functionality $this->__('foobar'); won't work in the templates. Some details on how ...


10

These tables would not update on runtime You need to run Refresh Statistics from: Reports -> Statistics -> Refresh Statistics If you want to run it from cronjob follow this link: https://magento.stackexchange.com/a/243187/31910


9

The reporting collections work a bit differently that the Mage_Core_Model_Abstract/CRUD collections. The CRUD collections will have a SQL query assigned immediately at instantiation. The reporting collection, however, initializes its SQL statement during its load operation. You can see this in the load method down in the abstract base class for all ...


9

The event is being fired from core. You can disable this event observer in a custom module (rather then editing core files, which is evil ;) ). Put this in your app/code/local/(VendorName)/(ModuleName)/etc/config.xml: <config> <frontend> <events> <catalog_controller_product_view> <observers&...


7

You have this? It looks like you have no resource model. <models> <awesome> <class>Super_Awesome_Model</class> <resourceModel>awesome_mysql4</resourceModel> </awesome> <awesome_mysql4> <class>Super_Awesome_Model_Mysql4</class> </models> You have to define ...


7

You can left join the catalog_category_product table to match products in your "exclude category", then filter your collection to only return products with no matches in the joined table: This should work, given the "exclude" category as $excludeId: $products2->joinTable( ['exclude_category' => 'catalog/category_product'], 'product_id=...


7

Go to Admin -> Reports -> Refresh Statistics, then select the reports you want to refresh, then hit the submit button. Once refresh, go back to the report, and select the required to and from dates, then click on the show reports button. You should see the report as required. If there is still nothing, the you may need to dig around in the ...


6

In Magento 2, local.xml.sample file is located in pub/errors/ You just need to rename local.xml.sample to local.xml Now, the error log will not be generic but detailed like this You can also turn on developer mode in Magento 2 by entering this line in Magento CLI: php bin/magento deploy:mode:set developer Referrence source: http://magentoexplorer.com/...


6

There's a fantastic little extension out there that does most of the heavy lifting for you, kalenjordan/custom-reports. Here is some more info on magemail.co. Install the extension, go to Reports > Special Reports > Add Report, name it 'Customers that have not ordered in the past 30 days' and paste your SQL in there. Then save it, and click 'Table'. You'll ...


6

Solutions: Yes this is known bug caused by the middle name attribute in recent versions of Magento. Here is the solution for this issue, we need to insert records for middle name attribute for old customers, here is the script to update database table require 'app/Mage.php'; Mage::app('default'); $db_read = Mage::getSingleton('core/resource')->...


6

You should rewrite magento core block Mage_Adminhtml_Block_Report_Product_Sold_Grid, here is the solution: <blocks> <adminhtml> <rewrite> <report_product_sold_grid>Namespace_Module_Block_Adminhtml_Order_Grid</report_product_sold_grid> </rewrite> </adminhtml> </blocks> and ...


6

Here is the solution... Create new module Vendor/Module/etc/module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Vendor_Module" setup_version="2.1.0"> <sequence> <module ...


5

You can use set column_css_class and header_css_class as no-display to the column you want to hide. This will hide your column from the admin grid. However, this column will be present in the exported csv or xml. $this->addColumn('YOUR_COLUMN_ID', array( 'header' => Mage::helper('YOUR_HELPER_NAME')->__('YOUR_COLUMN_NAME'), 'width'...


5

Go to Admin -> Reports -> Refresh Statistics, then select the reports you want to refresh, then hit the submit button. Once refresh, go back to the report, and select the required to and from dates, then click on the show reports button. You should see the report as required. If there is still nothing, the you may need to dig around in the ...


5

By default, Magento 2 shows the most viewed product in Magento Admin > DASHBOARD > choose tab Most Viewed Products. The _prepareCollection() method in vendor/magento/module-backend/Block/Dashboard/Tab/Products/Viewed.php is used for selecting products. We can copy some code lines from _prepareCollection() above. For example, in your block, use the following ...


5

Yes, it is possible. First, pass "reportTypes" argument to your cron class by using di.xml like below <type name="Vendor\Module\Cron\CronFile"> <arguments> <argument name="reportTypes" xsi:type="array"> <item name="sales" xsi:type="string">Magento\Sales\Model\ResourceModel\Report\Order</item>...


5

Replace class Createdat extends Magento\Sales\Model\ResourceModel\Report\Order\Createdat { With class Createdat extends \Magento\Sales\Model\ResourceModel\Report\Order\Createdat { You have forgot to add \ before base class. Remove var folder.


5

open app\code\core\Mage\Adminhtml\Block\Report\Product\Sold\Grid.php and put the below code in _prepareColumns() function You can move Grid.php in your local folder as well or can override it in custom module. $this->addColumn('sku', array( 'header' => Mage::helper('reports')->__('Product Sku'), 'index' =>'sku' ));


4

There is a method _afterLoadCollection() in Mage/Adminhtml/Block/Widget/Grid.php that can be overrided to remove/add columns for export or display with $this->_isExport. NOTE: Adding this to the _prepareCollection() won't work as the collection filters will not have been submitted, resulting in the entire collection dumped minus any filtering. ...


4

Collections First start out with a basic script including the Magento core, instantiating Mage::app() with store ID 0 (admin) and using the following code to retrieve an order collection in this case filtered by date. $collection = Mage::getModel('sales/order')->getCollection() ->addAttributeToFilter('created_at', array( ...


4

Sounds like Magento's cron is failing for some reason on the server. I'd try manually running the cron script and monitor the PHP error log and Magento Exception log, or using a tool like n98-magerun to manually run individual cron jobs and see what sort of errors happen.


4

including the ones that are not used by any products. Then you need your attribute collection and left join the products. Left join is not supported by the collection join() method, so use the underlying Zend_Db_Select. Code $attributeCode = 'color'; $attribute = Mage::getModel('eav/entity_attribute')->loadByCode(Mage_Catalog_Model_Product::ENTITY, $...


4

Try building your reports like this: $category = Mage::getModel('catalog/category')->load({category_id}); $reports = Mage::getResourceModel('reports/product_collection') ->addAttributeToSelect('*') ->addOrderedQty() ->addCategoryFilter($category) ->setOrder('ordered_qty', 'desc'); I mean ...


4

2 issues may be here, First the timezone one - There’s been an issue for some time with the date pickers in the admin screens being in inconsistent timezones. Internally everything is saved to the database in Universal Time (essentially GMT) and the user facing elements such as date pickers and report results should be shifted to your locale’s time, ...


4

Answer This is a hard limit imposed by Magento in the Mage_Adminhtml_Block_Report_Grid class - though it can be overridden. If you'd like to change it there aren't really a bunch of options. I would rewrite the report grid itself: Create a module which rewrites Mage_Adminhtml_Block_Report_Customer_Totals_Grid and overrides the setting at the parent class ...


4

For any product, you can set the product_id to the report collection /** * @param int $id * * @return mixed */ public function getProductCount($id) { /** * @var \Magento\Catalog\Model\Product\Interceptor $product */ //Get Object Manager Instance $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); //Load ...


Only top voted, non community-wiki answers of a minimum length are eligible