Approach in upgrading/re-working front-end workflow and dependencies

I am in the process of upgrading/re-working our front-end workflow and dependencies (largely driven by the deprecated Bower).

I have moved from Bower to Yarn and also introduced Webpack Encore (https://symfony.com/doc/3.4/frontend.html) which I intended to replace Grunt entirely with.

I don’t get the chance to tackle front-end work often and now i’ve hit a bit of a wall trying to work out what to do with my AMD modules, which look like this:

define('homepage', ['jquery'], function($  ) { var homepage = {      init: function() {          document.addEventListener('DOMContentLoaded', function () {             $  ('.expand-list-icon').on('click', function () {                 if ($  (this).find('svg').attr('data-icon') == 'plus' ) {                      $  (this).find('svg').attr('data-icon', 'minus');                 } else {                      $  (this).find('svg').attr('data-icon', 'plus');                 };             });         });      },      stickyNav: function() {         // another function in here...     }  }; return homepage;  }); 

I call them from my Twig templates like this:

<script type="text/javascript"> require(['homepage', 'jquery'], function(homepage) {     homepage.init();     homepage.stickyNav(); }); </script> 

I have around 20 modules like this which rely on jQuery and Bootstrap. My JavaScript isn’t very complex so if I had to convert the AMD modules to something else to allow them to fit in with Webpack then I would be willing to do that. My question is – convert them to what and how?

Any advice or conversation is greatly appreciated.

Magento 2 Error: Product disappeared on frontend, one store view only

We are having a weird problem since some days after the shop running for months without trouble.

On one day (only thing we did were some backup-operations on the database which might have caused this), – suddenly all product disappeared on frontend, showing “Wir k├Ânnen keine Produkte entsprechend dieser Auswahl finden”, “we could not find any products for this selection”. – This happened on the default store view, german – the other store views, french and english are not affected

When we open and save on product in backend, it sometimes shows up in front-end for some seconds. However, they disappear again with each indexer run.

Another point: After resignating yesterday evening, the products “just” have been back this morning. I don’t know what indexer run made them disappear some time later.

Magento 2.1.13, managed server

Anyone has an idea or help for this issue -and probably broken database?

What we did until now: – reindexed many times, cleared and flushed cache – saved many products in top- and store view – saved category in top- and store view – deleted the flat tables in database, reindexed

No effect on all.

What we did not do until now is setup:upgrade and rebuild the production static files because we are experiencing a php-problem on the development site on the same server. We want to avoid that we could end up with a non-productive site after that due to the php problem.

Frontend registration form doesn’t save data only redirects to wp-login

I have another wordpress dilemma… I’ve built a frontend registration form, but for some reason whenever a user tries to register it doesn’t work, and they get redirected to wp-login.php.

The following code does 5 things:

  1. gets user fields from a form (at the bottom),
  2. validates the data,
  3. inserts a new user into the database on success,
  4. logs the new guy in,
  5. sets the current_user to the new user

Here is the form / form head:

<?php $  err = ''; $  success = '';  global $  wpdb, $  PasswordHash, $  current_user, $  user_ID;   if(isset($  _POST['task']) && $  _POST['task'] == 'register' ) {   $  pwd1 = $  wpdb->escape(trim($  _POST['pwd1'])); $  pwd2 = $  wpdb->escape(trim($  _POST['pwd2'])); $  first_name = $  wpdb->escape(trim($  _POST['first_name'])); $  last_name = $  wpdb->escape(trim($  _POST['last_name'])); $  email = $  wpdb->escape(trim($  _POST['email'])); $  username = $  wpdb->escape(trim($  _POST['username']));  // if( false ) { if( $  email == "" || $  pwd1 == "" || $  pwd2 == "" || $  username == "" ) {     $  err .= "Please don't leave out any required fields.<br>"; }  if(!filter_var($  email, FILTER_VALIDATE_EMAIL)) {     $  err .= "Invalid email address.<br>"; }  if(email_exists($  email) ) {     $  err .= "Email already exist<br>."; }  if($  pwd1 <> $  pwd2 ){     $  err .= "Passwords do not match.<br>"; }  // if no error if ($  err == "") {     $  user_id = wp_insert_user(          array (             'first_name' => apply_filters('pre_user_first_name', $  first_name),             'last_name' => apply_filters('pre_user_last_name', $  last_name),             'user_pass' => apply_filters('pre_user_pass', $  pwd1),             'user_login' => apply_filters('pre_user_login', $  username),             'user_email' => apply_filters('pre_user_email', $  email),             'role' => 'subscriber'          )     );      if( is_wp_error($  user_id) ) {         $  err = 'Error on user creation.';     } else {          if(isset($  _REQUEST['redirurl'])) {             $  url = $  _REQUEST['redirurl']; // holds url for last page visited.         } else {             $  url = '/'; // default page for          }         header("Location:$  url");             do_action('user_register', $  user_id);          $  success = 'You\'ve successfully registered';          $  creds['user_login'] = $  username;         $  creds['user_password'] = $  pwd1;         $  creds['remember'] = true;         $  autologin_user = wp_signon($  creds, false); // automatically log the new user in          $  user = wp_set_current_user($  user_id); // set the current user to the user who just registered      }  }  } ?> <div class="alignleft"> <p>     <?php if($  sucess != "") { echo $  sucess; } ?> <?php if($  err != "") { echo $  err; } ?> </p> </div> <div class="<?php echo $  err ? '' : 'hidden animated fadeInDown duration2'; ?>" id="registrationForm"> <!-- Start form --> <form method="post" action="/login">     <?php var_dump($  _POST); ?>     <h1>Register</h1>     <h3>Account Detail</h3>     <!-- <input type="hidden" name="redirurl" value="<? echo $  _SERVER['HTTP_REFERER']; ?>" /> -->     <p>         <label>Username*</label>         <input type="text" value="" name="username" id="username" />     </p>     <p>         <label>Password*</label>         <input type="password" value="" name="pwd1" id="pwd1" />     </p>      <p>         <label>Confirm Password*</label>         <input type="password" value="" name="pwd2" id="pwd2" />     </p>      <h3>Contact</h3>     <p>         <label>Email*</label>         <input type="text" value="" name="email" id="email" />     </p>     <p>         <label>First Name</label>         <input type="text" value="" name="first_name" id="first_name" />     </p>     <p>         <label>Last Name</label>         <input type="text" value="" name="last_name" id="last_name" />     </p>                    <p>         <button type="submit" name="btnregister" class="button" >Submit</button>         <input type="hidden" name="task" value="register" />     </p> </form> </div><!-- end registration form --> 

And here is the snippet from the functions.php file that doesn’t let wordpress redirect to wp-login.php on login errors:

/** * Disable redirection upon login error */ function no_wordpress_errors(){   return header('Location: /login/?login=failed');   exit; } add_filter( 'login_errors', 'no_wordpress_errors' ); 

hint: there may be MANY things wrong with this code.

Thanks for your help!

Jill