Skip to main content

Posts

Integrity constraint violation: 1052 Column 'created_at' in where clause is ambiguous

When trying to filter sales order grid with From and To dates it was redirecting to dashboard.after that again i tried to open sales order grind it is generating reports in reports file it showing. "Integrity constraint violation: 1052 Column 'created_at' in where clause is ambiguous" means it is finding a another created_at field. because when we adding or joining the other table then it has also a field named as created_at. So below is the  solution for this error. magento that created_at is of the main_table not of my custom table. Find the below code in the sales order grid.php file. $this->addColumn('created_at', array(            'header' => Mage::helper('sales')->__('Purchased On'),             'index' => 'created_at',             'type' => 'datetime',             'width' => '100px',         )); ...

SOAP-ERROR: Encoding: string … is not a valid utf-8 string

I have a web service built using the Zend Framework. One of the methods is intended to send details about an order. I ran into some encoding issue. One of the values being returned contains the following: productname™ The webservice is returning the following fault: SOAP-ERROR: Encoding: string 'productname\xc3...' is not a valid utf-8 string Solution ::::  the code which caused that problem was: $value['name'] = substr($_product->getName(), 0, 40); changing substr to mb_substr seems to solve the issue: $value['name']  = mb_substr( $_product->getName() , 0, 40, 'utf8');

Magento 2.1.6 Product Grid page count and record count issue when programmatically adding filter using different methods

I have found a method that works. It seems that the Category view, regardless of a filter being applied or not, will  ALWAYS  use the Catalog Search module. Knowing that, we can override the following class to add a custom filter. Magento\CatalogSearch\Model\ResourceModel\Fulltext\Collection   But it's not that simple, first we have to create a custom filter in an xml document. Here are the steps: Step 1 Create a search_request.xml file in  Company/RegionManager/etc/search_request.xml . For my example I used the following code, you can replace any instance of deal_active with your custom attribute. Including the $deal_active$ <?xml version="1.0"?> <requests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   xsi:noNamespaceSchemaLocation="urn:magento:framework:Search/etc/search_request.xsd">  <request query="catalog_view_container" index="catalogsearch_fulltext">         <queries>     ...

Magento How do I enable free shipping in backend only (for order entry)

1>  Override or your custom shipping method file        app/code/core/Mage/Shipping/Model/Carrier/Freeshipping.php       or        app/code/local/ YourCompany/NewModule/Model/Carrier/ShippingMethod.php 2> You can find      public function collectRates(Mage_Shipping_Model_Rate_Request $request)   And add below two code in function          if (!Mage::app()->getStore()->isAdmin())) {             return false;         }      after below these two lines         if (!$this->getConfigFlag('active')) {             return false;         } And set to active in backend You can place the code in local if you dont want to overwrite the core This should work

If you want discount sorting in product list page(category page)

1> First need to create discount attribute for products. 2> After creation that copy  app/code/core/Mage/Catalog/Mo del/Resource/Product/collection.php in local folder app/code/local/Mage/Catalog/Mo del/Resource/Product/collection.php open the file find below bit of code around 1572      if ($attribute == 'price' && $storeId != 0) {             $this->addPriceData();             $this->getSelect()->order("price_index.min_price {$dir}");             return $this;         } after that Add below code if ($attribute == 'discount') {             //determine the discount percent value             $this->addExpressionAttributeT oSelect('discount', '(({{price}} - special_price) / {{price}})', array('price'));             ...

magento2 get all customizable option from products

create test file in root directory and place the below code excute it with domain/test.php <?php     //THis is test     echo '<pre>';     error_reporting(0);     ini_set('display_errors', 1);     use Magento\Framework\App\Bootstrap;     include('app/bootstrap.php');     $bootstrap = Bootstrap::create(BP, $_SERVER);     $objectManager = $bootstrap->getObjectManager();     $url = \Magento\Framework\App\ObjectManager::getInstance();     $storeManager = $url->get('\Magento\Store\Model\StoreManagerInterface');     $websiteId = $storeManager->getWebsite()->getWebsiteId();     $state = $objectManager->get('\Magento\Framework\App\State');     $state->setAreaCode('frontend');     //$product = $objectManager->get('\Magento\Catalog\Model\Product')->load('2331');     $productCollection = $objectM...