Jump to content

Product Accessories not showing up on live site


Joyplaz

Recommended Posts

Hello, I'm having a random issue that I can't get to the bottom of.

I've selected my chosen related products (product accessories) for a few of my products in the back office product page, but none of them show up on my product page on the front office.

When I var_dump $accessories, it returns an empty array.  If I use the method getAccessoriesLight on the product.tpl file and var_dump the result, at least I get the id's of the related products (although the name doesn't come out), but at least it's not an empty array.  It shows there's something there.

All of this, however, works perfectly on my localhost environment.  The same exact files work fine.   Below the product, there are the related products.

All of the products and related products are in stock with large quantities, so that's not the problem.  I've been digging around various files like product controller and classes/product, but I still can't figure out what's causing it not to work on the live site.  Maybe there's some issue with the getAccessories method, idk, again it all works fine on localhost.

So the question is: why is $accessories coming out as an empty array on the live site?

Link to comment
Share on other sites

Ok, I found a bit of a hack.  I don't know how bad it is though.

In classes/Product.php in the getAccessories method, I commented out "unset($result[$k]);"  like this....

foreach ($result as $k => &$row) { 
            if (!Product::checkAccessStatic((int)$row['id_product'], false)) {
                //unset($result[$k]);
                continue;
                 
            } else {
                $row['id_product_attribute'] = Product::getDefaultAttribute((int)$row['id_product']);
                
            }
        }

Again I don't know if this will cause errors in other ways, but for now, it works.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...