0

I have to write code for getting product count.it is working fine but i want to know where the count record comes?

public function getProductCount($id)
{

    $prodData = $this->_prodCollection->addViewsCount()->getData();

    if (count($prodData) > 0) {
        foreach ($prodData as $product) {
            if ($product['entity_id'] == $id) {
                return (int) $product['views'];
            }
        }
    }

    return 0;
    }

2 Answers 2

0

$productData is an array and the count definition is from here https://www.php.net/manual/en/function.count.php

1
  • what about the table name?from where it get count?
    – usman
    Aug 19, 2019 at 7:39
0

After wasting half of the day finally i find the table name i.e report_event.Basically whenever a page is requested a row is added in this table and when we call method addviewscount() it return array of products which are in report_event table and then we apply filter on entity_id it will return the product count .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.