PHP & Magento Developer in Minnesota

Thank you for visiting my website. I’m Nick Bartlett and have over ten years professional experience as a web developer with both frontend and backend skills. I’m one of a handful of Zend PHP 5 certified engineers in Minnesota and have years of experience contracting for local and remote companies.  If you or your company needs help with any of the below areas, please contact me through this website or email nick at bartlett dot com.

  1. Object Oriented PHP 5
  2. High performance, high traffic PHP websites
  3. MySQL 5
  4. JavaScript / Jquery
  5. HTML/CSS
  6. Magento
  7. WordPress
  8. Zend Framework
  9. Yii Framework

Magento 2: cron “Too late for the schedule” message in cron_schedule table

I ran into this issue today where every cron job would get created a few seconds after when it was supposed to execute. Because of this it would fail to run.

Notice the “send_notification” cron job at the top was executed, but then never finished and the “Too late for the schedule” message started shortly after. Geil Berkers also encountered this issue with Magento 2 in his post https://gielberkers.com/solving-too-late-for-the-schedule-with-magento-crons/ .

The issue with that cron job caused all subsequent crons to become too late for the schedule. As a temporary solution I manually entered a date in the “finished_at” column of the “send_notification” record and within a few minutes all crons started running again.


Magento 2: Add grid column with a link in each row

I was tasked with adding a column with a link in each row to a custom grid in the Magento 2 admin panel. This grid does not use Ui Components. It took quite a while to find the solution, so I’m posting here to save for later and also for your viewing. This file is \Block\Adminhtml\$area\Grid.php and adds a “Delete” link to each row. The below sample uses a value for “id” for each data item in the collection (“index”), and adds an “id” URL variable with the id value to the hyperlink.

protected function _prepareColumns()
{
	//.... other columns here
 
	$this->addColumn('action', array(
		'header' => __('Action'),
		'width' => '100',
		'type' => 'action',
		'getter' => 'getId',
		'actions' => array(
			array(
				'caption' => __('Delete'),
				'url' => array('base' => '*/config_cms_page_field/delete'),
				'field' => 'id'
			)
		),
		'filter' => false,
		'sortable' => false,
		'index' => 'id',
		'is_system' => true,
	));
	return parent::_prepareColumns();
}

Further enhancements might include adding a confirmation popup once the delete link is clicked. For that we’d use this instead of the “url” array key. The trouble I had is what variable is used for the “id” of each row. If you can figure it out please let me know. A view renderer may be needed for this.

'onclick' => 'deleteConfirm("'.__('Are you sure you want to delete this?').'", \'' . $this->getUrl('*/config_cms_page_field/delete', ['id' => 111]) . '\')',

Solved: Windows 10 updater stuck checking for updates

I upgraded from windows 7 to windows 10 and the automatic windows updates never worked. It always got stuck on this screen saying “checking for updates”.
checking for updates

The fix was doing a couple things. First, download this offline update tool http://download.wsusoffline.net/ and run it as described here https://www.howtogeek.com/247380/how-to-fix-windows-update-when-it-gets-stuck/ . For me, this didn’t even work. It found and applied some updates, but there were a dozen or so that could not get downloaded and installed. However, WSUS offline update did tell me which updates were still missing. Below is the output from the program.

17:00:45.06 - Listing ids of missing updates (please be patient, this will take a while)...
21:59:37.04 - Done.
Listing ids of installed updates...
Listing update files...
Warning: Update kb3127945 (id: 15d7f98f-d025-4ea5-89aa-6fbb09a41e73) not found.
Warning: Update kb3141535 (id: 1ff05279-5627-4993-a62e-4f11ee47ad31) not found.
Warning: Update kb3127890 (id: 0db092b3-c980-4ee6-9b56-54c5790bac86) not found.
Warning: Update kb3191829 (id: dbd12cba-5172-4d0c-8b53-82bcff57f799) not found.
Warning: Update kb3191827 (id: 4c304c75-1b13-4a99-b5b5-c51cef236e66) not found.
Warning: Update kb3191830 (id: bf943a21-4c4c-400b-9fda-dde26cc8867b) not found.
Warning: Update kb4017094 (id: 633a4cc1-35c9-40b9-9714-7cf158168751) not found.
Warning: Update kb3191836 (id: a32e6e50-5224-4987-ae74-24e8698aa25b) not found.
Warning: Update kb2596904 (id: 158250e3-4ef3-47ef-acf3-908145be487a) not found.
Warning: Update kb3191895 (id: 596424f1-aa0d-4d62-bb50-9368bf96df75) not found.
Warning: Update kb3191835 (id: 2366268b-d998-4c53-94cf-f69ab4823a38) not found.
Info: Skipping update kb890830 (Malicious Software Removal Tool) due to matching black list entry.

I then went to Microsoft’s website https://www.microsoft.com/en-us/download/details.aspx?id=55067 and downloaded and installed each of these one by one. Once this was done, the updater worked again and pulled down more updates. Problem Solved.


Importing wordpress database error “Invalid default value for .. “

While moving my wordpress blog to the new Google Cloud Hosting setup, the database would not import. This is due to MySQL being setup in strict mode by default in MySQL version 5.7 . One solution on the internet is to set MySQL’s SQL_MODE to “NO_ENGINE_SUBSTITUTION”, but Google knows better and won’t let you do that for security purposes. They do provide an option https://cloud.google.com/sql/docs/mysql/flags to alter the settings and allow for invalid dates. In the drop down as pictured, select “Allow Invalid Dates”. Then your wordpress database import will work.


Prevent iPhone from zooming when entering text

The iPhone likes to zoom into form elements when entering text. This is great, but once you’re finished entering text, the zoom remains and leaves an undesirable horizontal scrollbar and generally poor user experience until (if) they figure out they need to zoom back out. The below code will prevent the zooming in the first place.

/* prevent iphones from zooming in when entering text */
@media screen and (-webkit-min-device-pixel-ratio:0) { 
	select, textarea, input[type="text"], input[type="password"], input[type="datetime"], input[type="datetime-local"], input[type="date"], input[type="month"], input[type="time"], input[type="week"], input[type="number"], input[type="email"], input[type="url"], input[type="search"], input[type="tel"], input[type="color"] { font-size: 16px; }
}